Home > Software engineering >  Best Practises for auto-login on Ionic Capacitor React
Best Practises for auto-login on Ionic Capacitor React

Time:11-12

Is it possible to auto login users when they open the app after their first login?

I'm not sure what is the best way to implement auto login. One of the best options to me is to create refresh-token after the first login. Refresh-token will have a couple of months of lifespan. So far localStorage seems like the only option to store it.

Is this way of creating auto login is a good option? Is there a better way to do create auto login?

CodePudding user response:

What most apps do is auto show the biometrics in the login screen if the user allow it before. This allows to auto login instead of the user typing out whole username and password.

CodePudding user response:

It totally depend on your product and how you want your app's behaviour. Every option can be good in a scenario. I usually save refresh token in the local storage and load it on app start (before removing the splash screen or loading etc) and consider the user "logged in" when the token is present, until I realize from a request that the token is not valid (anymore) then I'd delete the token from memory and local and redirect the user to login page or something.

  • Related