我正在开发一个带有Ionic Framework的应用程序,我在Android上做了一个测试,到目前为止它运行良好,除了几分钟不活动后,该应用程序要求用户使用凭据重新登录。
我希望用户永远不必重新登录"记住我"功能可能吗?
如何进行?
这是我的控制器:
.controller('loginController',['$scope', '$firebaseArray', 'CONFIG', '$document', '$state', function($scope, $firebaseArray, CONFIG, $document, $state) {
// Perform the login action when the user submits the login form
$scope.doLogin = function(userLogin) {
if($document[0].getElementById("user_name").value != "" && $document[0].getElementById("user_pass").value != ""){
firebase.auth().signInWithEmailAndPassword(userLogin.username, userLogin.password).then(function() {
$state.go("tab.favorites");
}, function(error) {
// An error happened.
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/invalid-email') {
alert('Enter a valid email.');
return false;
}else if (errorCode === 'auth/wrong-password') {
alert('Incorrect password.');
return false;
}else if (errorCode === 'auth/argument-error') {
alert('Password must be string.');
return false;
}else if (errorCode === 'auth/user-not-found') {
alert('No such user found.');
return false;
}else if (errorCode === 'auth/too-many-requests') {
alert('Too many failed login attempts, please try after sometime.');
return false;
}else if (errorCode === 'auth/network-request-failed') {
alert('Request timed out, please try again.');
return false;
}else {
alert(errorMessage);
return false;
}
});
}else{
alert('Please enter email and password');
return false;
}//end check client username password
};// end $scope.doLogin()
}])