Javascript 使用firebase authWithPassword时定期注销
我在iOS上有一个phonegap应用程序,使用firebase进行身份验证。登录操作如下所示:Javascript 使用firebase authWithPassword时定期注销,javascript,ios,cordova,firebase,ionic,Javascript,Ios,Cordova,Firebase,Ionic,我在iOS上有一个phonegap应用程序,使用firebase进行身份验证。登录操作如下所示: var afterLogin = function(error, authData) { if (error) { console.log(error); messenger.error(error.message); return; } $scope.loggedIn = $auth.check(); $scope.$ap
var afterLogin = function(error, authData) {
if (error) {
console.log(error);
messenger.error(error.message);
return;
}
$scope.loggedIn = $auth.check();
$scope.$apply();
$sync.sync();
messenger.success('Logged in');
};
$scope.doLogin = function() {
mixpanel.track('login');
if (!$scope.loginForm.email && !$scope.loginForm.password) {
messenger.error('Enter email and password then tap login');
return;
} else if (!$scope.loginForm.email) {
messenger.error('Enter your email then tap login');
return;
} else if (!$scope.loginForm.password) {
messenger.error('Enter your password then tap login');
return;
}
ref.authWithPassword({
email : $scope.loginForm.email,
password : $scope.loginForm.password
}, afterLogin);
}
我检查用户的状态,如下所示:
check: function() {
var authData = ref.getAuth();
if (authData) {
mixpanel.identify(authData.uid);
mixpanel.people.set({
"$email": authData.password.email
});
}
return !!authData;
}
它一开始工作正常,但用户在12-24小时不使用该应用程序后会注销并重新登录。也许当应用程序内存不足时?显然,这是相当令人沮丧的,不知道是什么原因造成的。会话长度设置为24周,仍然存在问题
Firebase版本:2.1.2
角度:1.3.6
使用用户名和密码进行身份验证后的localStorage日志:
注销一天后返回:
cookie的内容是否已登录,其中没有firebase内容:
这是Firebase中的一个参数 在Firebase的仪表板上。 单击Login&Auth
然后在第一段中,输入并选择会话长度。您可以选择所需的小时数/周数等。您可以在此处添加更多详细信息,以帮助我们了解并重新编写该问题。上面的代码似乎不太可能与您正在使用的代码完全相同。你还没有包括任何版本信息,这肯定会造成这样的细微差别。您还没有列出您采取的任何故障排除步骤或排除的可能原因,例如,是否从本地存储中删除令牌?代币还存在吗?如果是这样的话,你的过期值是多少?@Kato我已经添加了一些关于这个问题的更多信息。Hey Tom,谢谢你提供的更多信息。这确实描绘了一幅更好的画面。在我看来,phonegap没有保存cookie/存储信息。可能是因为它在内部使用file://并且不允许使用cookies?您可以检查localStorage/Cookie以查看是否正在存储auth吗?只是尝试了一下,无法重新编程。我们可以存储这些内容,并且会话正在被持久化。@加藤我已经添加了cookie的日志。看起来里面跟firebase没有任何关系。