Goufa Tarek
Goufa Tarek

Reputation: 31

Angular check if user logged in is admin

I have this line to check if the current user is admin or normal user

if (this.responseData.user.appUserRole === 'ADMIN') {
        //....... 
      } else {
        //......
      }

it's safe to store value like isAdmin in local storage? or there is another way to put in variable to use it another place?

Upvotes: 0

Views: 292

Answers (1)

IlCorsaroNero
IlCorsaroNero

Reputation: 419

Depends... for example is the site vulnerable to XSS attack local storage is a not safe place to save user credentials in general.

The other reason is that people can clear their cache. In some cases in my opinion is better to save this information directly using cookie.

I hope that my explanation is clear

Upvotes: 2

Related Questions