【问题标题】:Firebase Auth AngularJsFirebase 身份验证 AngularJs
【发布时间】:2017-07-11 08:57:39
【问题描述】:

使用 Firebase 在 AngularJS 中创建登录应用程序,并获取 这些问题。

1 .TypeError: auth.$createUser 不是函数

  1. 错误:permission_denied:客户端无权访问所需数据。
    var app = angular.module('weatherApp',
        ['ngRoute', 'firebase'])
        .constant('FIREBASE_URL', 'https://weatherapp-9a183.firebaseio.com');

   app.controller('registerController',
        ['$scope', '$firebaseObject', 'FIREBASE_URL', function ($scope, $firebaseAuth, FIREBASE_URL) {

        var ref = new Firebase(FIREBASE_URL);
        var auth = $firebaseAuth(ref);

        auth.$createUser({
            email: "email@pla.com",
            password: "123"
        });

    }]);

【问题讨论】:

    标签: angularjs firebase web


    【解决方案1】:

    使用最新版本的 firebase 和 angularfire。

    1. Firebase 最新版本:3.6.6
    2. Angualrfire 最新版本 2.3.0

    要使用电子邮件和密码创建新用户,您应该使用link 中指定的 createUserWithEmailAndPassword 方法。如下代码。

    var auth = $firebaseAuth();
    auth.$createUserWithEmailAndPassword("email@pla.com","123").then(function(){
    console.log("Successfully Created") or alert("Successfully Created");
        //Once user is created you can see it in the Authentication (Users) tab.
    }).catch(function(err){
    console.log(err) or alert(err)
    });
    

    我不知道您在这里尝试完成什么。但据我所知,这是使用 $firebaseAuth 创建新用户的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-08
      • 2016-01-25
      • 1970-01-01
      • 2020-04-01
      • 2022-12-10
      • 2013-12-30
      • 1970-01-01
      相关资源
      最近更新 更多