AngularFire身份验证注册

时间:2013-12-08 17:04:33

标签: javascript angularjs angularfire

我正在尝试为angularFire firebase实施注册。我有各种形式的登录工作,包括本地和社交解决方案。但我有点不知道如何为那些不使用社交媒体网站的人创建注册。简单的登录确实有效,但我必须自己添加用户名和密码。有没有人必须处理这个或有任何人找到AngularFire简单登录注册的解决方案。我真的很感激任何帮助。为了让您了解我的目标是登录控制器。

var ref = new Firebase("https://<<myfirebase>>.firebaseio.com");
angularFireAuth.initialize(ref, {
scope: $scope, name: "user",
callback: function(err, user) {
  if (!err) {
      console.log("User :", user);
  } else {
      console.log("Error :", err);
  }
}
});
$scope.login = function() {
console.log("logging in");
var username = $scope.form.email;
var password = $scope.form.password;
angularFireAuth.login('password', {
    email: username,
    password: password,
    rememberMe: false
  });
};

$scope.loginTwitter = function() {
    console.log('loggin in via Twitter');
    angularFireAuth.login('twitter');
};

$scope.loginFacebook = function() {
    console.log('loggin in via Facebook');
    angularFireAuth.login('facebook');
};

$scope.loginGithub = function() {
    console.log('loggin in via Github');
    angularFireAuth.login('github');
};

$scope.logout = function() {
  angularFireAuth.logout();
};

1 个答案:

答案 0 :(得分:0)

使用angularFireAuth.createUser方法以编程方式创建新用户(在大多数情况下,基于注册表单上的用户输入):

function createNewUser(email, pw) {
  angularFireAuth.createUser(email, password, callback);
}

成功创建用户(或出现错误)时将调用回调。通常,您需要将此方法绑定到表单的提交按钮。