I’m storing an auth token in local storage (LocalStorageModule) that I delete upon sign out. This is working correctly. However, if I sign in with another user successfully the auth token from the previous user will be used by my angular service instead of the new one.
Normally, in angular projects I get around this issue by calling:
$window.location = '/';
which results in a browser refresh.
This seems to work correctly in Chrome with an ionic project, but in the ios emulator I’m not seeing a refresh which results in the wrong auth token sent with api requests. How can I do the equivalent of a hard refresh?
Login:
-> write data in localstorage
-> redirect to root state ‘/’ there my rootCtrl reads the localstorage one time and saved the data.
Logout:
-> delete localstorage and clear saved data
Login again:
-> write new data in localstorage
-> rootCtrl checks - if the auth data is already set -> if not: read localstorage
-> and here are your new data
That’s basically my workflow as well. On further inspection, I think my issue maybe related to how I’m setting the authorization headers in my CurrentUser Service and angular models.
Until I do a hard refresh, the old value will be passed for api calls. Logging CurrentUser.authorization_header() on sign in shows the new correct value, but the api calls are somehow passing the old value. On closer look how I’ve had to do a hard refresh is probably a bandaid to the real problem and not related to ionic but any suggestions would be helpful.
in my form i done so many changes those will still reflecting even i logout and login again. how to make all this as default view. even if i chagned the toogle buttons and scroll the view etc.