【问题标题】:$firebaseAuthProvider <- $firebaseAuth <- Auth$firebaseAuthProvider <- $firebaseAuth <- 验证
【发布时间】:2017-05-21 02:28:01
【问题描述】:

我在 Firebase 中创建了 1 个用户帐户,我只需要对其进行身份验证,但出现如下错误 $firebaseAuthProvider &lt;- $firebaseAuth &lt;- Auth

我的 app.js:

    var mypractice = angular.module("firebase.appauth", ['practicecontroller','firebase','ngRoute','ngMessages' ]);

服务方法:我为Authentication创建了一个单独的工厂:

    mypractice.factory("Auth", ["$firebaseAuth",
        function($firebaseAuth) {
            var ref = $firebaseAuth(new Firebase("https://firabaseurl.com"));

            return $firebaseAuth(ref);
        }
    ]);

控制器:

practicecontroller.controller("loginctrl", ['$scope', '$http', 'Auth', function ($scope, $http, Auth) {
    $scope.auth = Auth;
    $scope.auth.$onAuth(function (authData) {
        $scope.authData = authData;
    });

    $scope.login = function () {
        Auth.$authWithPassword({
            email : $scope.username,
            password : $scope.password
        })
        .then(function (authData) {
            console.log('Logged in as:', authData.uid);

            window.location.href = "#/login/home"

        })
        .catch (function (err) {
            console.log('error:', err);
            //$state.go('login');
        });
    };

【问题讨论】:

  • 您使用的是什么版本的 Firebase 和 AngularFire?

标签: javascript angularjs firebase firebase-authentication


【解决方案1】:

你不注入$firebaseAuth,你只是直接使用firebase。见:https://firebase.google.com/docs/auth/web/manage-users

firebase.auth()...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-26
    • 2018-01-17
    • 2021-05-13
    • 2020-12-18
    • 1970-01-01
    • 2018-07-25
    • 2019-03-03
    • 2018-11-20
    相关资源
    最近更新 更多