Reputation: 3848
I am using ngCordova-oauth for sign up with facebook and google. App is working fine but it always use inAppBrowser
to open webview and login. It does not detect if the user has already login in device.
how can it be achieved in ionic/cordova app that if user has already login in fb or google then take token from there rather then open webview everytime and signing up?
Upvotes: 3
Views: 666
Reputation: 16629
How I do this as follows
1 - Let the user login for the first time via ngCordova-oauth
2 - Get the authentication token
and save it, Im using $localStorage
3 - When the user opens the app for next time, I send the authentication token
to the server and validate it (before the step 1)
4 - If the authentication token
is valid, skip the login and move on
5 - If the user logs out
, I clear the authentication token
, which will invalidate the step 3, and force to log again
Upvotes: 2