I am trying to get my app to use firebase auth.. At this stage I have my login controller successful, but it logs in and the next second it's logged out.
.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;
});
};
});
I have a service where I get my firebase object:
.service('userAuth', ["$firebaseAuth", function($firebaseAuth) {
return $firebaseAuth();
}
What will be the better way for authentication state so I can use it throughout my site?
I tried using the $onAuth but i get this error
TypeError: Cannot read property '$onAuth' of undefined