I was wondering if anyone has used ionic and firebase and allowed persistent authentication. When I create an IPA/APK and download the app to my device, every time I close the app I have to log in again.
Upon login with $authWithPassword the call back includes uid and token. If I use get import ngStorage as a dependency, how can I use uid and token to persist auth?
For login, the user login calls the login function which is linked to the Auth.login function in my factory.
login: function(user) {
return auth.$authWithPassword({
email: user.email,
password: user.password
}, function(error, authData) {
switch(error.code) {
case "INVALID_EMAIL":
console.log("Log in with a valid email.");
break
case "INVALID_PASSWORD":
console.log("Password or email is incorrect");
break
default:
console.log("Enter a valid email and password");
}
})
.then(function(authData) {
console.log("login: Logged in with uid: ", authData);
$localStorage.uid = authData.uid;
$localStorage.token = authData.token;
})
.catch(function(error) {
alert("Error: " + error);
});
I am not sure how I would persist authentication with uid and token. Is it possible to do it without the user password?
Thanks in advance for help.