My login action returns information about the logged in user if they are admin or not, say (isAdmin: true)
I can keep this information between the component until a browser refresh or similar action. But I lose this information after a browser refresh. I m confused how to retain this value.
I am using localStorage
and sessionStorage
to save some non-sensitive information. But this information is sensitive and the user should not be allowed to edit/view this value.
Is there any way to accomplish this using angular2?
I would make an API call to the server or where you have the user's information each time the App starts. So, when I refresh the App I get the information from first hand and I don't have to store it in sessions, I just store the data in an object and use it.
When you login generate a token and save it in session and send it along with the API call that I mentioned earlier.
That would be my approach:
Hope it helps or at least gives you some valuable ideas... Let us know how you solve your issue! :D