How to change password using Firebase in Flutter

前端 未结 4 1873
一向
一向 2021-01-24 06:46

I want to change current user password using Firebase in Flutter. Can any one help me on how to implement change password method?

4条回答
  •  离开以前
    2021-01-24 06:59

    I know this is a late post, but now it's possible to change the password of the logged-in user. Make sure to notify the user to log in again since this is a sensitive operation.

    void _changePassword(String password) async{
       //Create an instance of the current user. 
        FirebaseUser user = await FirebaseAuth.instance.currentUser();
       
        //Pass in the password to updatePassword.
        user.updatePassword(password).then((_){
          print("Successfully changed password");
        }).catchError((error){
          print("Password can't be changed" + error.toString());
          //This might happen, when the wrong password is in, the user isn't found, or if the user hasn't logged in recently.
        });
      }
    

提交回复
热议问题