【发布时间】:2015-03-28 23:11:13
【问题描述】:
我在 iOS 上有一个 phonegap 应用,使用 firebase 进行身份验证。登录是这样完成的:
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 内容):
【问题讨论】:
-
您可以在此处添加更多详细信息,以帮助我们理解和重现该问题。上面的代码似乎不太可能是您正在使用的代码的精确复制。您没有包含任何版本信息,这肯定会产生这样的细微差别。而且您没有列出您采取的任何故障排除步骤或您排除的可能原因(例如,令牌是否已从本地存储中删除?令牌是否仍然存在?如果是这样,
expires的值是多少@987654321 @?) -
@Kato 我已经添加了有关该问题的更多信息
-
嗨,汤姆,感谢您提供更多信息。这确实描绘了一幅更好的画面。在我看来,phonegap 没有保存 cookie/存储信息。可能是因为它在内部使用
file://并且不允许使用 cookie?您能否检查 localStorage/cookies 以查看是否正在存储身份验证? -
刚刚尝试过,无法重现。我们能够存储这些,并且会话正在保持。
-
@kato 我已经添加了 cookie 的日志。那里似乎与firebase没有任何关系。
标签: javascript ios cordova firebase ionic