Jim McDermott
Jim McDermott

Reputation: 171

Firebase password resets

I'm trying to create a password reset mechanism and am stuck. Any suggestions how to do this with Firebase basic email/password authentication

Upvotes: 17

Views: 16652

Answers (4)

Rob DiMarco
Rob DiMarco

Reputation: 13266

[Engineer at Firebase - Update 2014-01-27]

Firebase Simple Login now supports password resets for email / password authentication.

Each of the Simple Login client libraries has been given a new method for generating password reset emails for the specified email address - sendPasswordResetEmail() on the Web and Android, and sendPasswordResetForEmail() on iOS.

This e-mail will contain a temporary token that the user may use to log into their account and update their credentials. This token will expire after 24 hours or when the user changes their password, whichever occurs first.

Also note that Firebase Simple Login enables full configuration of the email template as well as the sending address (including whitelabel email from your domain for paid accounts).

To get access to this feature, you'll need to update your client library to a version of v1.2.0 or greater. To grab the latest version, check out https://firebase.google.com/docs/.

Also, check out https://firebase.google.com/docs/auth/web/password-auth for the latest Firebase Simple Login - Web Client docs.

Upvotes: 12

user8264
user8264

Reputation: 1928

This was the first google result that came up when trying to figure out my issue.. for anyone who uses yeoman angularfire generator but would like to add the send email feature, this should work. add the following to the simple login factory in simpleLogin.js:

   resetPassword: function(emailIn){
       return auth.$resetPassword({
          email: emailIn
        }, function(error) {
          if (error) {
            switch (error.code) {
              case "INVALID_USER":
                console.log("The specified user account does not exist.");
                break;
              default:
                console.log("Error resetting password:", error);
            }
          } else {
            console.log("Password reset email sent successfully!");
          }
      });
    },

and call it from your login.js file

  $scope.resetPassword = function(email){

  simpleLogin.resetPassword(email)
};

Upvotes: 0

nazbot
nazbot

Reputation: 1697

This is something that Firebase doesn't do very well. As you'll notice it requires the user to remember their old password. Usually if you want to reset a password it's because you've forgotten it. Hopefully the improve the methods they provide for account management.

Upvotes: 4

abrkn
abrkn

Reputation: 2061

https://www.firebase.com/docs/security/simple-login-email-password.html

authClient.changePassword(email, oldPassword, newPassword, function(error, success) {
  if (!error) {
    console.log('Password change successfully');
  }
});

Upvotes: 0

Related Questions