0

I have developed single page application in angular 5 which uses session storage to store some navigation parameters, flags, info etc. but session storage values can be seen/modified by end user under browser's Application -->session Storage tab.

Temporarily I have encrypted those values but that is not permanent fix.

How can I hide those values using Angular? Any other suggestions/solutions?

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Kiran Gurade
  • 21
  • 1
  • 5
  • Try cookies then. Go through https://stackoverflow.com/q/19867599/8252164 – samuellawrentz Jul 18 '18 at 09:48
  • I had a same Issue, so this is what I did: In my authguard as the query prams are saved in session storage I navigate the user to normal link without query parameters and instead use the data from the session storage... – Immad Hamid Jul 18 '18 at 09:58

2 Answers2

0

I had a same Issue, so this is what I did:

In my AuthGuard as I get the query prams I save it in session storage in encrypted form and then I navigate the user to link without query parameters and as the user hit that link I decrypt the values that are present in session storage and show the result...

Immad Hamid
  • 789
  • 1
  • 8
  • 21
0

You can create Storage event to subscribe the session storage value , hear is an example code

 this.message$ = fromEvent<StorageEvent>(window, 'storage').pipe(

     filter((event) => event.storageArea === sessionStorage),
     filter((event) => event.key === 'isLoggedIn'),
     map((event) => event.newValue)
);

In the html , you can do something like this ,

 <button *ngIf="(message$ | async) == 'true' ? true : false"> 
 Logout</button>