教程:http://www.thinkster.io/angularjs/wBhtRLWHIR/6-authenticating-users-with-a-service火力簡單的登錄教程丟失的用戶
我下面這個教程,它好像我只要他們註冊失去我的用戶。
這裏是我的auth.js廠:
'use strict';
app.factory('Auth', function($firebaseSimpleLogin, FIREBASE_URL, $rootScope){
var ref = new Firebase(FIREBASE_URL);
var auth = $firebaseSimpleLogin(ref);
var Auth = {
register : function(user) {
return auth.$createUser(user.email, user.password);
},
signedIn : function() {
// PROBLEM: authUser is always null
console.log(auth.user);
return auth.user !== null;
},
logout : function() {
auth.$logout();
}
};
$rootScope.signedIn = function() {
return Auth.signedIn();
};
return Auth;
});
這裏是我的auth.js控制器:
'use strict';
app.controller('AuthCtrl', function($scope, $location, Auth){
if (Auth.signedIn()) {
$location.path('/');
}
$scope.register = function() {
Auth.register($scope.user).then(function (authUser) {
console.log(authUser);
$location.path('/');
});
};
});
在工廠signedIn下的console.log總是空。任何想法斷開連接?註冊本身工作正常,在註冊時在控制器的console.log中填入authUser
。
我可以提供其他任何有用的信息嗎? – turbo2oh
這是什麼版本的angularFire?它看起來可能是一個版本問題。例如,最新的angularFire不會自動登錄(如thinkster教程所示)。 – Kato
我檢查了作爲本教程一部分的bower.json文件,它將〜0.7.1描述爲angularfire版本。在index.html中,它也看起來像它包括一個簡單的登錄從angularfire,以及firebase-simple-login.js – turbo2oh