Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding easy-peasy & keychain usage #31

Closed
rajinpangkalpundai opened this issue Sep 28, 2020 · 4 comments
Closed

Question regarding easy-peasy & keychain usage #31

rajinpangkalpundai opened this issue Sep 28, 2020 · 4 comments

Comments

@rajinpangkalpundai
Copy link

Hello @HarishJangra ,

I have a project that uses OTP as the authenticator to log in into the app. Could you please show me the Login Navigation Flow and how do i use easy-peasy? i want to store the phone number and token to the local storage, while your initial boilerplate uses username and password instead. Kindly need your help asap. btw, thank you very much for the repo, it really helps cutting down some development time.

@HarishJangra
Copy link
Owner

Hi @rajinpangkalpundai
You can definitely store anything in keychain due to library restrictions the keys in the store will be username and password only. You can refer to react-native-keychain for more info.

So You can store mobile or other info as username and password

and when you get the stored data here you can change like this

export const getLoginCredentials = async () => {
	try {
		const credentials = await Keychain.getGenericPassword();
		console.log("keychain get data ", credentials);
		if (credentials) {
			return {YOURKEYONE: credentials.username, YOURKEYTWO:credentials.password};
		}
		return false;
	} catch (e) {
		console.log("Cannot retrieve keychain data", e);
		return false;
	}
};

replace YOURKEYONE & YOURKEYTWO to your custom keys.

@rajinpangkalpundai
Copy link
Author

YOURKEYONE

i've checked react-native-keychain, and yes, it has limitation to only store in 'username' and 'password'. Another question is:
Is it possible to use AsyncStorage on 'Services' folder to save my login credentials and later use it to maintain the app state (session)?

Thank you for your quick reply, i really appreciate it.

@HarishJangra
Copy link
Owner

Yes you can use it in whatever way you want.

@rajinpangkalpundai
Copy link
Author

Yes you can use it in whatever way you want.

Awesome! thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants