0

I have a question, I would appreciate if someone can help me. I am doing a login with different roles: The app file (which loads the application) sends a role 0, which would be my login (therefore it shows the user, password and button fields)

When I validate that the user does exist, I need to be validated, if the person is a user, administrator, with different permissions among others.

1 Answers1

0

Not sure if I understood perfectly your question, but here is a solution:

  • you set up a context, to be able to keep your state about the permissions between multiple components easily
  • you make a login request and receive your permissions
  • you dispatch/set/save your permissions
  • if you use Redux for example, you can set up in your store to save those permissions and whenever you need them you just verify if they are true/false

Also, here is an example for auth, and I recommed you to use react-router: https://reacttraining.com/react-router/web/example/auth-workflow

Context Api: https://reactjs.org/docs/context.html

Redux: https://redux.js.org/basics/store How to implement Role based restrictions/permissions in react redux app?

sylar12
  • 107
  • 1
  • 8