【发布时间】:2016-10-27 01:47:25
【问题描述】:
尝试使用 firebase 对用户进行身份验证。使用 firebase 2.xx 启动了我的应用程序,但即使在升级到 Firebase 3.xx 之后,仍然抛出 错误“onAuthStateChanged 不是函数”。
这就是我的登录功能的样子-
.controller('HomeCtrl', ['$scope','$location','CommonProp','$firebaseAuth', '$firebaseObject',function($scope,$location,CommonProp,$firebaseAuth,$firebaseObject) {
var firebaseObj = $firebaseObject(rootRef);
var loginObj = $firebaseAuth(firebaseObj);
$scope.SignIn = function($scope, user) {
event.preventDefault(); // To prevent form refresh
var username = user.email;
var password = user.password;
loginObj.$signInWithEmailAndPassword({
email: username,
password: password
})
.then(function(user) {
// Success callback
console.log('Authentication successful');
$location.path("/welcome");
CommonProp.setUser(user.password.email);
}, function(error) {
// Failure callback
console.log(error);
});
}
}]);
【问题讨论】:
标签: angularjs firebase angularfire firebase-authentication