In the Firebase Forge, navigate to the 'Auth' section. Under the 'Authentication Providers' header, select the 'Email & Password' option, and check 'Enable'.
It's now just called "Simple Login". See https://pbs.twimg.com/media/BjMkJAjCMAAvCGT.png
Now when we register, we should be redirected to the posts page and a log out button should appear in the navbar.
This doesn't happen. I spent a long time not understanding what was going on, thinking I had something wrong with my ng-show="signedIn()"
. I traced it all the way up to auth.user == null
, thinking something was broken. Eventually I figured out that I'm not actually being signed in.
See Firebase Simple Login docs for createUser:
Creates a new account for the specified email address. Note that this function does not log the user in automatically; you must call login( ) after account creation completes.
I made this work as described by the tutorial by calling $scope.login()
inside the success callback for register:
$scope.register = function() {
Auth.register($scope.user).then(
function(authUser) {
console.log(authUser);
$scope.login();
$location.path('/');
},
function(error) {
$scope.error = error.toString();
}
);
};