Where to store user data?

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!
March 20th 20 at 11:28
1 answer
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.
The fact of the problem is reading not a problem, the problem is storing it, and read.
I have implemented this solution to hide information. I can without any problems to get data from dB, but where to keep them and how to apply? - Frederique.Reinger commented on March 20th 20 at 11:33
And what exactly is the problem to store the role and read?
If it is a front - store anywhere, even in the variable save. to read from a variable is also no problem. If you have no problems to get "data" (I understand the role) from the database that do not understand what you still lack.
Formulate a clear question. - delbert_Marquardt commented on March 20th 20 at 11:36

Find more questions by tags Node.jsExpress.js