Occasionally users open up my app and discover that they are logged out, and I am trying to uncover all the potential reasons why…
Whenever a user logs in, I get an auth token from the server which I then store in $http.defaults.headers.common.Authorization and I also place it in local storage.
When the user opens up the app again I just check to see if the token exists in local storage and I reset the $http.defaults… If the server sends me a 401, then I intercept it and log the user out. Done. Tokens don’t expire or get reset in my backend, so users really shouldnt get a 401 unless something changes on the client side.
Where do you store auth tokens? Local storage & indexdb aren’t persistent. Is my only reliably persistent option the sqlite plugin?