Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71530

How to handle persisting log in & token time to live expiration?

$
0
0

@nb1990 wrote:

I have a mobile & web app with JWT authentication. The token expires every hour and is refreshed. Now where I'm stuck is how to handle persisting the login so when the user comes back to the app they can skip the login screen if they are authenticated.

Here is some pseudo code I wrote

 // Check if token is null
      // Return false & pop back to root
 // Check if token is expired
    // Attempt to refresh
      // If refresh successful continue to page 1
    // Else return false & pop back to root
 // Anything else: Pop back to root

I was thinking of maybe also creating a status which is saved to storage which is either 'loggedIn' or null and checking that along with checking if the token is null. Not sure if its needed though.

If anybody has an examples on a good way to implement this or a smarter way that would be greatly appreciated.

Also would it be a good idea to check on every page to make sure the user is still authenticated?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71530

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>