Jump to content
Fester

Can't hide pages/templates from guests

Recommended Posts

I'm trying to hide some of the pages on my website from users that are not logged in. I'm trying to achieve this by changing the settings of the page's template like so:

post-3259-0-11319100-1437140557_thumb.jp

This hides the page from my navigation which is good, but it doesn't block the user from surfing to the page directly which I think should be happening if I interpret the settings correctly?

When I first encountered this issue I was running PW 2.6 but I've since updated to 2.6.8 alas to no avail.

I hope someone will be able to help me out and I will be happy to provide more information about this issue if need be.

I'm currently working around this issue by adding a $user->isLoggedin() include to my pages but this isn't as clean as setting the permissions directly from the CMS imo.

Share this post


Link to post
Share on other sites

Hi Fester,

If I understand your question, you can unpublish the page by going to the page you want to hide -> settings -> check unpublished. (The admin and editor can see it trough pressing the view button in the tabs)
 

If this ain't what youre looking for I am sorry, my PHP skills don't reach so far.

Cheers

Share this post


Link to post
Share on other sites

That's not exactly what I'm looking for, I want to make the page visible to any user that's logged in. Some users on my website don't have access to the CMS.

Share this post


Link to post
Share on other sites

This hides the page from my navigation which is good, but it doesn't block the user from surfing to the page directly which I think should be happening if I interpret the settings correctly?

Your interpretation is correct, and the settings you've posted here should indeed deny access to the page for guests (non-logged-in users).

Testing on the 2.6 branch, I can't seem to easily reproduce similar issue. There's a couple of things I'd like to check first, though:

  1. Do you have any additional permission-related modules installed – Dynamic Roles, UserGroups, PageEditPerUser, anything like that?
  2. Any other modules you can think of that could cause this behaviour? Do you have any third party modules installed at all?
  3. Are you absolutely sure that the page that is publicly viewable is using this template? Just trying to be extra thorough here :)
  4. Do you have any kind of caching going on, a proxy running in front of the site, content cached in CloudFlare, etc.?

All in all this kind of issue would be much easier to debug if there was some way to see it in action, and/or if you could provide easy steps for reproducing it on a clean install of ProcessWire. It would be very helpful if you could test this with a clean installation, and see if it happens there too; if not, it could be something weird with this particular site, but at least that would give us some pointers about what to check next.

  • Like 2

Share this post


Link to post
Share on other sites

@Fester your settings look correct to me. A page using that template would only be visible to superuser, editor and registered user roles. So something must be overriding access control in your case, like Teppo suggested. Double check that you are testing with a guest user. By that, I mean logout and test, open in different browser (that's not logged in), or open the page in an Incognito/Private window. I think Teppo mentioned all the possible things, and I don't have more to add to it, but please let us know what you find. 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for your time guys I apologize if my initial post was a bit brief. In response to Teppo's questions:

Do you have any additional permission-related modules installed – Dynamic Roles, UserGroups, PageEditPerUser, anything like that?

I have two modules that might be interfering with the access of the page, the first one being FrontendUser and the second one is Persistent Login for users. 

Any other modules you can think of that could cause this behaviour? Do you have any third party modules installed at all?

I'm running six modules in total, I previously mentioned two and the other four are FormHelper, Email New user,  Force Password Change and Upgrades.

Are you absolutely sure that the page that is publicly viewable is using this template? Just trying to be extra thorough here  :)

I understand your thoroughness but I'm encountering this issue on multiple pages that are using different templates

 

Do you have any kind of caching going on, a proxy running in front of the site, content cached in CloudFlare, etc.?

As far as I know there's no server side caching going on, I've tested this on multiple devices and private browsing windows too so I don't think it's a client caching thing either.

And @Ryan

So something must be overriding access control in your case 

 Could you give an example of what could be overriding the access control? I can't think of anything besides modules and custom PHP code to change the users access (of which there is none in my site).

Again thank you so much for taking your time to help me out with this issue! I'm going to see if I'm able to reproduce the issue on a clean install of processwire and report back with my findings.

Share this post


Link to post
Share on other sites

Ok I've found the issue!

Cause of my issue: I batch assigned the registered_user role to a bunch of users on my website. But in doing so I also assigned the registered_user role to the default guest user.

This of course caused anyone who was not logged in to have the registered_user role and made them able to view pages they weren't supposed to.

Sorry for overlooking this issue before posting here and thanks again for your help everyone!

  • Like 1

Share this post


Link to post
Share on other sites

Glad to hear that you got it sorted! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DanielKit
      Hi. I'm currently stuck at the login page in my project. Once I enter my admin username and my password and press login, nothing happens. The page just reloads. However, the URL changes from http://myipaddress/processwire to http://myipaddress/processwire/?login=1. I've checked all of my server settings, and to my knowledge, all seems to be fine there. I don't know where to go from here.. Thanks in advance!
    • By VeiJari
      Hi, this is the first we are trying to make a page that has only one type of user that has access to every page. 
      The other users should only have a given access to specific pages, not to the whole template.
      My structure
      -Field -Organisation -Project -Report I want that the "measurer" role only has access to "project x" and it's children, but no view access to every project, organisation or field. I've tried to do this with https://modules.processwire.com/modules/page-edit-per-user/ but it still needs a view access to the whole tree to see the "project x" page. Or is there something I haven't figured out?
      Maybe I have to make it via the API: a select field in the "organisation" template where the admins could add the users and then I use hook to update the privileges?
      Have you done something like this and how did you accomplish it?
      Any help would be appreciated.
       
    • By Chris Bennett
      Hi all, I am going round and round in circles and would greatly appreciate if anyone can point me in the right direction.
      I am sure I am doing something dumb, or missing something I should know, but don't. Story of my life 😉

      Playing round with a module and my basic problem is I want to upload an image and also use InputfieldMarkup and other Inputfields.
      Going back and forth between trying an api generated page defining Fieldgroup, Template, Fields, Page and the InputfieldWrapper method.

      InputfieldWrapper method works great for all the markup stuff, but I just can't wrap my head around what I need to do to save the image to the database.
      Can generate a Field for it (thanks to the api investigations) but not sure what I need to do to link the Inputfield to that. Tried a lot of stuff from various threads, of varying dates without luck.
      Undoubtedly not helped by me not knowing enough.

      Defining Fieldgroup etc through the api seems nice and clean and works great for the images but I can't wrap my head around how/if I can add/append/hook the InputfieldWrapper/InputfieldMarkup stuff I'd like to include on that template as well. Not even sure if it should be where it is on ___install with the Fieldtype stuff or later on . Not getting Tracy errors, just nothing seems to happen.
      If anyone has any ideas or can point me in the right direction, that would be great because at the moment I am stumbling round in the dark.
       
      public function ___install() { parent::___install(); $page = $this->pages->get('name='.self::PAGE_NAME); if (!$page->id) { // Create fieldgroup, template, fields and page // Create new fieldgroup $fmFieldgroup = new Fieldgroup(); $fmFieldgroup->name = MODULE_NAME.'-fieldgroup'; $fmFieldgroup->add($this->fields->get('title')); // needed title field $fmFieldgroup->save(); // Create new template using the fieldgroup $fmTemplate = new Template(); $fmTemplate->name = MODULE_NAME; $fmTemplate->fieldgroup = $fmFieldgroup; $fmTemplate->noSettings = 1; $fmTemplate->noChildren = 1; $fmTemplate->allowNewPages = 0; $fmTemplate->tabContent = MODULE_NAME; $fmTemplate->noChangeTemplate = 1; $fmTemplate->setIcon(ICON); $fmTemplate->save(); // Favicon source $fmField = new Field(); $fmField->type = $this->modules->get("FieldtypeImage"); $fmField->name = 'fmFavicon'; $fmField->label = 'Favicon'; $fmField->focusMode = 'off'; $fmField->gridMode = 'grid'; $fmField->extensions = 'svg png'; $fmField->columnWidth = 50; $fmField->collapsed = Inputfield::collapsedNever; $fmField->setIcon(ICON); $fmField->addTag(MODULE_NAME); $fmField->save(); $fmFieldgroup->add($fmField); // Favicon Silhouette source $fmField = new Field(); $fmField->type = $this->modules->get("FieldtypeImage"); $fmField->name = 'fmFaviconSilhouette'; $fmField->label = 'SVG Silhouette'; $fmField->notes = 'When creating a silhouette/mask svg version for Safari Pinned Tabs and Windows Tiles, we recommend setting your viewbox for 0 0 16 16, as this is what Apple requires. In many cases, the easiest way to do this in something like illustrator is a sacrificial rectangle with no fill, and no stroke at 16 x 16. This forces the desired viewbox and can then be discarded easily using something as simple as notepad. Easy is good, especially when you get the result you want without a lot of hassle.'; $fmField->focusMode = 'off'; $fmField->extensions = 'svg'; $fmField->columnWidth = 50; $fmField->collapsed = Inputfield::collapsedNever; $fmField->setIcon(ICON); $fmField->addTag(MODULE_NAME); $fmField->save(); $fmFieldgroup->add($fmField); // Create: Open Settings Tab $tabOpener = new Field(); $tabOpener->type = new FieldtypeFieldsetTabOpen(); $tabOpener->name = 'fmTab1'; $tabOpener->label = "Favicon Settings"; $tabOpener->collapsed = Inputfield::collapsedNever; $tabOpener->addTag(MODULE_NAME); $tabOpener->save(); // Create: Close Settings Tab $tabCloser = new Field(); $tabCloser->type = new FieldtypeFieldsetClose; $tabCloser->name = 'fmTab1' . FieldtypeFieldsetTabOpen::fieldsetCloseIdentifier; $tabCloser->label = "Close open tab"; $tabCloser->addTag(MODULE_NAME); $tabCloser->save(); // Create: Opens wrapper for Favicon Folder Name $filesOpener = new Field(); $filesOpener->type = new FieldtypeFieldsetOpen(); $filesOpener->name = 'fmOpenFolderName'; $filesOpener->label = 'Wrap Folder Name'; $filesOpener->class = 'inline'; $filesOpener->collapsed = Inputfield::collapsedNever; $filesOpener->addTag(MODULE_NAME); $filesOpener->save(); // Create: Close wrapper for Favicon Folder Name $filesCloser = new Field(); $filesCloser->type = new FieldtypeFieldsetClose(); $filesCloser->name = 'fmOpenFolderName' . FieldtypeFieldsetOpen::fieldsetCloseIdentifier; $filesCloser->label = "Close open fieldset"; $filesCloser->addTag(MODULE_NAME); $filesCloser->save(); // Create Favicon Folder Name $fmField = new Field(); $fmField->type = $this->modules->get("FieldtypeText"); $fmField->name = 'folderName'; $fmField->label = 'Favicon Folder:'; $fmField->description = $this->config->urls->files; $fmField->placeholder = 'Destination Folder for your generated favicons, webmanifest and browserconfig'; $fmField->columnWidth = 100; $fmField->collapsed = Inputfield::collapsedNever; $fmField->setIcon('folder'); $fmField->addTag(MODULE_NAME); $fmField->save(); $fmFieldgroup->add($tabOpener); $fmFieldgroup->add($filesOpener); $fmFieldgroup->add($fmField); $fmFieldgroup->add($filesCloser); $fmFieldgroup->add($tabCloser); $fmFieldgroup->save(); /////////////////////////////////////////////////////////////// // Experimental Markup Tests $wrapperFaviconMagic = new InputfieldWrapper(); $wrapperFaviconMagic->attr('id','faviconMagicWrapper'); $wrapperFaviconMagic->attr('title',$this->_('Favicon Magic')); // field show info what $field = $this->modules->get('InputfieldMarkup'); $field->name = 'use'; $field->label = __('How do I use it?'); $field->collapsed = Inputfield::collapsedNever; $field->icon('info'); $field->attr('value', 'Does this even begin to vaguely work?'); $field->columnWidth = 50; $wrapperFaviconMagic->add($field); $fmTemplate->fields->add($wrapperFaviconMagic); $fmTemplate->fields->save(); ///////////////////////////////////////////////////////////// // Create page $page = $this->wire( new Page() ); $page->template = MODULE_NAME; $page->parent = $this->wire('pages')->get('/'); $page->addStatus(Page::statusHidden); $page->title = 'Favicons'; $page->name = self::PAGE_NAME; $page->process = $this; $page->save(); } }  
    • By Pip
      Hi everyone!
      I'm trying out the Login/Register module for my site. Noted that the module assigns the newly registered user to login-register role. 
      Once you modify the login-register role's permissions, particularly adding page-edit, the new member role will be set to guest. 
      Thing is I'd like to grant my new users the power to create their own pages. Any advice? 
      Thanks. 
×
×
  • Create New...