Jump to content

role based processwire/page/


Spica
 Share

Recommended Posts

I want to build a rolebased admin page.

Actually I use a custom admin page to which the user is redirected after BE login, which is nice so far. So the user is put to something like processwire/page/rolebasedpage with a template myadmin.php.

I want now, to replace the pageoutput for processwire/page instead. I tried this in admin.php

if($this->user->hasRole("myrole")) {
	require($config->paths->adminTemplates . 'controller.php'); 
	return $this->page->render("myadmin.php");
} else {
	require($config->paths->adminTemplates . 'controller.php'); 
}

Is this a good way. And, as it does not work yet, how to do it right. Am I referencing the template uncorrect or is there a more fundamental misconception?

Link to comment
Share on other sites

Yes. But this does set global permission to the module. I want a different admin page for different roles, that do not have access to e.g. the tree. I now build a whole admin theme where roles get different outputs, e.g. just get access to own pages. This is the only way I see at the moment.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

I am trying to implement role based page restriction , by installing these two module.

AdminRestrictPageTree

ProcessDashboard

 

But I am getting redirection problem in every browser.

FireFox:

"The page isn't redirecting properly

 
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
 
    This problem can sometimes be caused by disabling or refusing to accept cookies.
"

 

Chrome:

This webpage has a redirect loop

Can you Help me with this issue.

Link to comment
Share on other sites

I had the same thing, and it was a result of permissions not being set properly for the dashboard.

On the Settings tab for your Dashboard page, the role (or roles) for your user should appear under "Who can access this page?".

If it doesn't, I'm not totally sure which of the following steps fixed it for me, but something worked!

First, make sure the "dashboard" permission is selected for the role (the permission should have been created by the module). And of course, check the role is assigned to the relevant users. Then go to the Modules page and click the Refresh button.

Then if that doesn't work, you may need to go to the permissions for the Admin template and under Access change "manage view and edit access" to Yes. Then hit Refresh on the modules page again.

By the way, a quick look inside the Dashboard module indicates it uses the technique Ryan suggests at https://processwire.com/talk/topic/276-creating-new-admin-page/, which may help with debugging.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...