Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changePassword() method in Firebase version 3

I'm using firebase ver 3.2.1 in my React Native iOS project. I read the log from version 2.4.2 here, there is a method named changePassword() which can be used to change user's password.

But when I look docs for Firebase ver 3.2.1 I can't find any method named changePassword(). So I'm wondering, is changePassword() method can not be used in Firebase version 3 anymore?

Thanks.

like image 353
yogieputra Avatar asked Sep 13 '16 10:09

yogieputra


1 Answers

Since Firebase v3.0, changePassword method is not available anymore. If you need to reset your user's password you can use custom email action handlers : https://firebase.google.com/docs/auth/custom-email-handler

The following user management actions require the user to complete the action using an email action handler: Resetting passwords

I recommend you read the documentation and you'll get started really quick to reset your user's password.

EDIT : If you don't need to reset the password but just update it, you can use the updatePassword method.

let user = firebase.auth().currentUser;
let newPassword = getASecureRandomPassword();

user.updatePassword(newPassword).then(() => {
  // Update successful.
}, (error) => {
  // An error happened.
});

Important: To set a user's password, the user must have signed in recently. See Re-authenticate a user.

More informations here : https://firebase.google.com/docs/auth/web/manage-users#set_a_users_password

Hope this helps !

like image 129
0x01 Avatar answered Sep 20 '22 18:09

0x01