【发布时间】:2017-05-21 02:28:01
【问题描述】:
我在 Firebase 中创建了 1 个用户帐户,我只需要对其进行身份验证,但出现如下错误
$firebaseAuthProvider <- $firebaseAuth <- 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