kianoush dortaj
kianoush dortaj

Reputation: 499

The best and safest place to store and retrieve user access information

From the server I get a list of places that the session user has access to. Now I want to store these roles where I can show or not display the route or buttons for the user. Where is the best place to store this data in Angular?

Upvotes: 0

Views: 103

Answers (1)

Robin De Schepper
Robin De Schepper

Reputation: 6365

Short answer

Inside of a service.

Why?

You mention that you receive a list of places from the server: the client can use for example Chrome's Developer Tools to inspect the network traffic and just read the list of places there.

You should secure the access to your routes and content server side, and don't worry about the client-side "security". The user has access to the full client-side source code. If the client-side environment can decrypt or access something, then eventually so can the client.

There's many kind of storage available on the client side: There's the LocalStorage API for persistent storage, or you can make an Angular service that transiently stores the retrieved role information. But just keep in mind that your user can read everything that you write in your Angular application, so trying to keep buttons or routes hidden won't work on power users going through your code.

Upvotes: 1

Related Questions