simpletut / Universal-React-Apollo-Registration

Open Source Universal User Registration System – NodeJS React Apollo GraphQL JWT MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How works ACL - Access control list?

rrfaria opened this issue · comments

For instance:
There is a page that it can be accessed by anyone once they are logged but each user has a different permission.
User x can read the article, but user y can do it and also edit the article and user z can do both but with a additional feature.

could be a nice feature if there is a page that we can set the permission to a certain user group and the just add users to each group.

How can I use this?

Is there something implemented?

My understanding is that you want to set multiple user access levels.

Currently you can only restrict access to pages based on if a user is logged in or not.

Please see:

https://github.com/simpletut/Universal-React-Apollo-Registration#restrict-access-authenticated-users-only

If you wish to add additional user access rights, you would need to extend the existing functionality.

For example, if you would like to create ‘user’ and ‘admin’ level access I would suggest the following implementation.

  1. Add a ‘userLevel’ field to the ‘Users’ schema. This should contain a numerical value for every user that represent their access rights. For example:

0 = basic
1 = admin

You may need to update the registration process to account for this new field.

  1. Whenever user’s login, we are using a higher order component ‘withSession’ and specifically the ‘GET_CURRENT_USER’ query to fetch user data and pass it as props to the relevant components.

My suggestion would be to update the query referenced above to return the new ‘userLevel’ and then create a new higher order component similar to ‘withAuth’ that restricts access dependant to the ‘userLevel’ and your custom criteria.

I will consider adding this feature for future releases.