Sidd Thota
Sidd Thota

Reputation: 2249

Angular 5 - Maintain Component Scope on browser Hard-refresh

I'm working on Angular 5, in which we have a sequential flow with each component making multiple API calls.

For Eg:

User Enters his/her details like name/dob/gender etc, on page1 form (component1), and click on next and using these details as request object a service passes these details onto component2, we make an API call on component2 and show username and other associated details on page2 (component2). If user hard-refreshes that page, I'd like to maintain the scope of the current component with user name on it which was passed into this by a service.

I don't want to handle this via localstorage/sessionstorage/cache, because we are dealing with sensitive data. Is there any better way to handle this case?

Upvotes: 0

Views: 96

Answers (1)

DeborahK
DeborahK

Reputation: 60558

By "hard refresh" I assume that you mean the refresh button? The refresh button restarts the application. So there is no place or technique that you can use to store the data in the app.

If you can't store it in any type of local storage, then you'll need to store it on the server.

Is there a reason that the user needs to use a "hard refresh"?

This article demonstrates a technique using local storage: https://netbasal.com/angular-2-persist-your-login-status-with-behaviorsubject-45da9ec43243

Note that it does not store the "sensitive" information. Rather it stores a token.

Upvotes: 3

Related Questions