Firebase Auth does not update after password reset

I can not imagine how to reset the Firebase Auth object after loading it for the first time.

I am looking for the value bool true in auth.password.isTemporaryPassword , which forces the user to reset their password. After the user has completed this procedure and reset, auth.password.isTemporaryPassword will remain true .

The only way I found is to register the user and log back in by updating the auth object.

Login:

 var ref = new Firebase(environment); $firebaseAuth(ref) .$authWithPassword({ email: email, password: password },sessionObj) .then(function(authData) { if (password.isTemporaryPassword === true) { $state.go('resetpassword'); } }) .catch(function(error) { deferred.reject(error); }); 

reset password:

 $scope.reset.oldPassword = "oldPass"; $scope.reset.newPassword = "newPass"; $scope.reset.email = "usermail"; ref.changePassword($scope.reset, function(err) { if(err) { ... } else { $state.go('home') } }) 

password.isTemporaryPassword remains true until I log into the system again, which seems hacked.

+5
source share
1 answer

You can use the onAuth function to listen for authentication status changes:

 ref.onAuth(function(authData) { //user authenticated & needs to change her password if(authData && authData.password.isTemporaryPassword) { $state.go('resetpassword'); } //else user is logged in with valid password else if(authData) { } //else user is logged out else { } }); 
0
source

All Articles