Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to change user password firebase

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

user.updatePassword(newPassword).then(function() {
  // Update successful.
}).catch(function(error) {
  // An error happened.
});
Comment

change password firebase

var user = firebase.auth().currentUser;
 if (user.password == state.password) {
   user.updatePassword(state.password).then(function() {
    // Update successful.
  }).catch(function(error) {
    // An error happened.
  });
 }
Comment

Change Password in firebase v9

import {
  EmailAuthProvider,
  getAuth,
  reauthenticateWithCredential,
  updatePassword,
} from "firebase/auth";

// 1) Reauthenticate credential 
reAuthenticateCredential(currentPassword: string, newPassword: string) {
    const user = getAuth().currentUser;
    const cred = EmailAuthProvider.credential(user.email, currentPassword);
    reauthenticateWithCredential(user, cred);
    this.changePassword(newPassword);
}

// 2) Then call update password function
changePassword(newPassword: string) {
    const user = getAuth().currentUser;
    updatePassword(user, newPassword)
      .then(() => {
        // Update successful.
        this.toasterService.notificationSuccess(
          message.PASSWORD_IS_UPDATED_SUCCESSFULLY
        );
        this.logout();
      })
      .catch((error: any) => {
        // An error happened.
        this.toasterService.notificationDanger(error.message);
      });
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: node js mongodb update by _id 
Javascript :: generate random number in node js 
Javascript :: how to delete node_modules 
Javascript :: javascript callback 
Javascript :: jquery on form submit call function 
Javascript :: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements 
Javascript :: scroll to top js 
Javascript :: react native header 
Javascript :: elasticsearch aggregation unique values 
Javascript :: object traversal javascript 
Javascript :: localstorage set 
Javascript :: node js get list of all names of object array 
Javascript :: find index in array javascript 
Javascript :: how to merge two objects into one in javascript 
Javascript :: is checked checkbox jquery 
Javascript :: math .round 
Javascript :: discord js bot embed user profile picture 
Javascript :: express param in url 
Javascript :: get first 10 characters of string javascript 
Javascript :: print all days names of a month 
Javascript :: router.push in vue 3 
Javascript :: how to change background color on scroll 
Javascript :: js click counter 
Javascript :: contains() js 
Javascript :: how to use uniqid 
Javascript :: js execute string 
Javascript :: build apk from react native 
Javascript :: javascript creeate utc date 
Javascript :: javascript loop object 
Javascript :: can you call a function within a function javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =