Jump to content
Orkun

How to make a Multi-User-System-Management for Frontend

Recommended Posts

How can i build multi-user-system for the frontend? I have an approach like:

Pagetree:

Login

        -Admin(Admin-Overview)

                  -- Veranstaltungen

                  -- Agenda/Daten

                  -- Multimedia

                  -- Veranstalter

                  -- Import/Export

                  -- Einstellungen

         -user-1(Overview)

                  -- Veranstaltungen

                  -- Agenda/Daten

                  -- Multimedia

                  -- Profil

                  -- Benutzer

         -user-2(Overview)

                  ''

                  ''

         ...

users: user-1, user-2

the users have the role: client

When the successfull login happens:

if($user->isLoggedin()){
	if($user->isSuperuser()){
		$session->redirect("./admin-overview/");
	}
	else if($user->hasRole("client")){	
		$session->redirect("./$user->name/");
	}
}

On the beggining of the _main.php where all the content will be loaded:

To avoid access to the content from another user from the url.

 if($user->isLoggedin()){
    if($page->name != $page404->name){
        if($user->name != $page->rootParent->name){
           $session->redirect("$page404->url");
        }
    }
        
 }

Am I on the right way or is this the completely false?

Can you give me a better approach, a better, safer way to achieve a multi-user-system/management for the frontend??

I must migrate an existing Web-Application that was build with yii to Processwire.

       

Share this post


Link to post
Share on other sites

It depends on the usecase / manageability. Beside of your suggested strategy you could also store all events / agendas / … under a single parent with just an additional pagefield, to link them to the different users. 

Share this post


Link to post
Share on other sites

It depends on the usecase / manageability. Beside of your suggested strategy you could also store all events / agendas / … under a single parent with just an additional pagefield, to link them to the different users. 

Could you explain that further? How should I handle the two interfaces Admin and User?

Do you mean for example:

Login

         -Dashboard

                  -- Veranstaltungen

                  -- Agenda/Daten

                  -- Multimedia

                  -- Veranstalter

                  -- Import/Export

                    -- Einstellungen

When the successfull login happens:

if($user->isLoggedin()){
     $session->redirect("./dashboard/");
	
}

And then for exmplae i create a new event under Events and while creating i can choose from the pagefield which users i want.

Then under the EventIndex-Template i list the events which has the selector like: 

if($user->isLoggedin()){
     $events = $pages->find("template=event, select_users=$user->name");
     
     foreach($events as $event){
      //List the events with template = event and select_user = $user->name
     }
	
}

select_users is the pagefield with the selection of the users.

Share this post


Link to post
Share on other sites

Kinda like that. But as I said it depends on the usecase if such a structure is better (not so much duplication, one page could have multiple users) or worse (harder to overview in the backend). 

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 jonatan
      "Permission “page-sort” for template “ ... ” not allowed (requires “page-edit” permission)"

      – This lovely error message is thrown at me, if, as implied by it, I try to add (to my "editor" role) the permission "page-sort" for a specific template, without the permission "page-edit" enabled for the same template.
      Seems like it's been mentioned a few times before but never properly answered, by e.g. @Robin S ... :  
      "Allow the granting of page-sort permission independent of page-edit": https://github.com/processwire/processwire-requests/issues/29
       
       
       


      Why do I wanna do this?:

      I have a page tree structure  🌳  as so:

      ________________________

      Category [C1]
      – Page a [C1_p] – Page b [C1_p] Different category [C2]
      – Page c [C2_p] – Page d [C2_p] ________________________

      The page "Category" has the page-template "C1",
      the pages "Page a" and "Page b" both have the page-template "C1_p".
      The page "Different category" has the page-template "C2"
      the pages "Page c" and "Page d" both have the page-template "C2_p".
       
      The two pages called "Category" and "Different category" do not have any content, they only serve as containers for pages belonging to that category.
       
      I want my "editor" role not to be able to do anything at all with these pages "Category" and "Different category"; i.e. I do not want my editor to be able to edit, move, unpublish, hide, lock, delete (or do anything else to) these category pages. 
      – So, I want my "editor" role to have the "page-edit" permission for pages with the templates "C1_p" and "C2_p", but not for the pages with the category templates "C1" and "C2",
      Also, I want my "editor" role to be able to move the pages with the templates "C1_p" and "C2_p" within their parent-pages. 


      Problem:

      But if I just simply add the "page-edit" and the "page-move" permissions for the "C1_p" and "C2_p" templates, then, using the "editor" role, I am not able to move these "C1_p" (and "C2_p") -template-based pages. I can actually click "MOVE" next to them and then move them, but... then I will be met by the error message "You do not have permission to sort pages using this parent - /Category/".  
      – So, I try to add the "page-sort" (description: "permission to sort child pages") permission to the "C1" and "C2" templates... but then trying to do so I am met by the initially mentioned error message   ! Permission “page-sort” for template “C1” not allowed (requires “page-edit” permission)  . 
      And, as mentioned, I do not want my editor role users to be able to edit these category ("C1" and "C2") pages...
      – what to do about this? 😅 
       
      All the best,
      Jonatan 
    • 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 snck
      Hey there,
      for a client website I need to implement a "reviewer" role. "Reviewers" should be able to review new (unpublished) articles to give feedback to editors, but not have the permission to change them. 
      I built a new "reviewer" role that only has page-view permissions for the respective templates, but this permission does not include viewing unpublished pages. How can I grant them access to the unpublished articles without giving them page-edit permission?
      Cheers,
      Flo
    • 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. 
    • By snck
      Hey,
      I want my editors to be able to use the page lister, especially the bookmarks. I added the page-lister permission to the editor role, but Page lister ("Find" menu item) does not show. Is there anything else I have to do? Links to bookmarks work for the editors, but I would be glad to show them the menu item as well.
      Maybe this has something to do with the long history of the site (started with ProcessWire 2.4 and upgraded to 3.0.148 over the years)?
      Thanks,
      Flo 
×
×
  • Create New...