Coder Social home page Coder Social logo

Comments (1)

simpletut avatar simpletut commented on June 11, 2024

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.

from universal-react-apollo-registration.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.