【发布时间】:2017-03-17 10:27:58
【问题描述】:
我正在使用 Angular 进行 Firebase 身份验证,我遇到了一个问题,$location.path 函数仅在我第二次点击后才调用,第一次,我运行这个 loginVerify,Firebase 将访问者身份验证为用户,但它没有路由到我的联系页面,我第二次单击时,Firebase 再次将访问者验证为用户并将用户路由到登录页面。谁能帮我找出原因?非常感谢!
源码:https://github.com/ptchiangchloe/Meet-Up-Event-Planner
这是我的现场版本:https://meet-up-event-planner-d45a4.firebaseapp.com/#!/
vm.loginVerify = function() {
firebase.auth().signInWithEmailAndPassword(vm.email, vm.password))
.then(function(response) {
console.log("Success!", response); // the first I run this fn, firebase authenticate the visiter is a user but it didn't route to my contact page
$location.path('/contacts');// the second time I click, firebase authenticate the visiter is a user again and route the user to my contact page
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorCode);
console.log(errorMessage);
$location.path('/');
});
}
【问题讨论】:
标签: javascript angularjs firebase routing firebase-authentication