Ich versuche, meine App zu Firebase Auth .. In diesem Stadium habe ich meine Login-Controller erfolgreich, aber es meldet sich an und die nächste Sekunde ist es ausgeloggt.
.controller('LoginCtrl', function ($scope, $location, userAuth) {
if ($scope.authData) {
console.log("User " + authData.uid + " is logged in with " + authData.provider);
} else {
console.log("User is logged out");
}
$scope.login = function() {
$scope.authData = null;
$scope.error = null;
userAuth.$signInWithEmailAndPassword($scope.loginemail, $scope.loginpassword)
.then(function(authData) {
$scope.authData = authData;
console.log(authData);
$location.path('/home');
$scope.$apply();
}).catch(function(error) {
$scope.error = error.message;
});
};
});
Ich habe einen Dienst, wo ich mein Feuerbasis Objekt erhalten:
.service('userAuth', ["$firebaseAuth", function($firebaseAuth) {
return $firebaseAuth();
}
Was wird der bessere Weg für die Authentifizierung Zustand sein, so kann ich es während meiner Website verwenden?
Ich habe versucht, den $ onAuth mit, aber ich bekomme diese Fehlermeldung
TypeError: Cannot read property '$onAuth' of undefined