There is a project for node angular express passport. There is a problem:
1) Record the author of the post (When saving to the database id of the user will stretch from req.user pre-passport records to information that I can't read with client)
2) Show the current user name and avatar as it is implemented on the toaster (stupid is a get request, where the user will be defined by id, from the same req.user, and the necessary information will be sent to the client) 3) Now the most important thing that I cannot understand. I need to hide information from the user with a certain role, but where and how do I get the user role I don't understand. 100% implementation is on the surface, but surfed a lot and found nothing. Need your help!
delbert_Marquardt answered on March 20th 20 at 11:30
There are two options:
1) to store role where you have stored the user (you didn't specify where it comes from - local database, oauth, XS what else) and to get a role as an attribute of the user in req.user
2) to make a table in your database where to store the role for each user for each id to store role. if you need to get the role to query the database with the id from the req.user to roles and to do what you need.
UI can get a role or token (e.g. if it's OAuth/OpenID), or to make a request to the server when you download the app/login and retrieve roles from there.