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 :: Cannot resolve taglib with uri http://java.sun.com/jsp/jstl/core 
Javascript :: list all functions in an object js 
Javascript :: js window.alert 
Javascript :: js get first letter of string 
Javascript :: Reached heap limit Allocation failed - JavaScript heap out of memory nodejs 
Javascript :: fetch data in next js 
Javascript :: vscode react cannot find moudle when import image 
Javascript :: error: node_modules/react-native-reanimated/src/index.ts: 
Javascript :: javascript download xlsx file 
Javascript :: jquery cdn in react 
Javascript :: trim string after - in jquery 
Javascript :: crear proyecto angular 
Javascript :: axios cancel previous request 
Javascript :: javascript stop the form from reloading 
Javascript :: generate html with javascript 
Javascript :: js capitalize first letter 
Javascript :: javascript array add end 
Javascript :: react js multiple import 
Javascript :: how to make @click in router-link vuejs 
Javascript :: regex expression for password validation form validation 
Javascript :: react set cookie 
Javascript :: vue cdn 
Javascript :: js get substring before character 
Javascript :: postasync json C# 
Javascript :: javascript regex generator 
Javascript :: nuxt progress false 
Javascript :: javascript set class of element 
Javascript :: typeorm findone subquery 
Javascript :: get client id socket io 
Javascript :: angular stoppropagatio 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =