Home > database >  How Can I open an application without login if one being opened already?
How Can I open an application without login if one being opened already?

Time:02-04

I have 5 different applications developed in react-native, I want give a better experience to my users, so if an application being logged I want the next one not to need to do login again if it is called from within the logged-in app. How Can I do it?

CodePudding user response:

There could be a lot of ways to do this, for me i use Redux for storing the Auth Token which i generate by Random string function, and i use 2 type of Stack 1) App Stack 2) Auth stack. So before that i wrap it inside a condition where it says { loginKey ?<AppStack/>:<AuthStack/> } where appStack is all the apps screens, AuthStack is login/signup screen and loginKey is redux state which stores the key one time (which we generate on successful login/signup). Other way is as mentioned in above answer using user - login state and check if login state is true then show user your main apps screen else show user login screen.

CodePudding user response:

ou can achieve this by using a shared state management solution like Redux or MobX to store the authentication state of the user. Once a user logs in, you can store their authentication information (e.g. token, username, etc.) in the shared store. Then, when a different app is launched, you can check the shared store to see if the user is already authenticated. If they are, you can automatically log them in without prompting them to enter their credentials again. This way, the authentication state is shared across all of your applications, providing a seamless experience for your users

  • Related