我将 AngularJS 与 firebase 一起用于 firebaseSimpleLogin。前一阵子有用,突然就不行了。登录部分工作正常,但新用户无法注册。
var userAuthRef = new Firebase(URL+"/userAuth");
$scope.loginObj = $firebaseSimpleLogin(userAuthRef);
$scope.userSignup = function(){
$('.signup.small.modal').modal('hide');
if ($scope.Password!="" && angular.equals($scope.PasswordFirst, $scope.PasswordConfirm)){
console.log($scope.Email + $scope.PasswordConfirm); ////the first log
$scope.loginObj.$createUser($scope.Email,$scope.PasswordConfirm)
.then(function(auth) {
console.log("reached here"); ////the second log
if (auth === null) {
console.log("Error creating user:", error);
} else {
console.log("User created successfully");
$scope.loginObj.$login("password", {
email: $scope.Email,
password: $scope.PasswordConfirm
}).then(function(user) {
console.log("Logged in as: ", user.uid);
userRef = $firebase(new Firebase(someURL+user.uid));
userRef.$set({username: $scope.Username, time: Date(), reported: 0});
$scope.user = userRef.$asObject();
}, function(error) {
console.error("Login failed: ", error);
});
}
}), function(error){
console.error("signup failed: ", error);
////Sign up failure log
};
}
else{
console.log("condition does not satisfy");
}
};
我很确定函数 userSignup() 被调用,因为第一个 console.log 确实打印了一些东西。然后我什至不知道 $createUser 是否被执行,因为控制台不再提供任何东西。
这些是 Firebase forge 的规则:
{
"rules": {
".read": true,
"$user": {
".write": true
}
}
}
$createUser 的用法错了吗?