我有一个内置firebase和angular的应用程序,我希望能够在刷新页面后让用户登录.现在我有一个登录屏幕,其中包含两个绑定到控制器的基本输入字段
this.email = "";
this.pass = "";
this.emessage = "";
this.loginUser = function() {
ref.authWithPassword({
email: this.email,
password: this.pass
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
this.emessage = error.message;
$scope.$apply();
} else {
dataStorage.uid = authData.uid;
$location.path('/projects');
$scope.$apply();
}
}.bind(this));
}
Run Code Online (Sandbox Code Playgroud)
这一切都很好,花花公子它可以工作,但是当用户刷新页面时,它们会被退回.有没有办法在控制器加载时查看用户是否已登录并自动重定向?谢谢!