Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flatter更改firebase用户的密码不起作用_Firebase_Flutter_Firebase Authentication - Fatal编程技术网

Flatter更改firebase用户的密码不起作用

Flatter更改firebase用户的密码不起作用,firebase,flutter,firebase-authentication,Firebase,Flutter,Firebase Authentication,我正在尝试为firebase用户实现更改密码 handleChangePassword(BuildContext parentContext) { return showDialog( context: parentContext, builder: (_) { return ChangePasswordPopUp( currentEmail: widget.email, auth: wi

我正在尝试为firebase用户实现更改密码

handleChangePassword(BuildContext parentContext) {
    return showDialog(
        context: parentContext,
        builder: (_) {
          return ChangePasswordPopUp(
            currentEmail: widget.email,
            auth: widget.auth,
            newPassword: (val) async {
              await widget.auth.changePassword(val);
            },
          );
        });
  }
用户在
ChangePasswordPopUp
中获得重新身份验证,并使用
ValueChanged newPassword
我正在呼叫
changePassword

Future<void> changePassword(String password) async {
    FirebaseUser user = await _firebaseAuth.currentUser();
    print(password);
    user.updatePassword(password).then((_){
      print("Succesfull changed password");
    }).catchError((error){
      print("Password can't be changed" + error.toString());
    });
  }
Future changePassword(字符串密码)异步{
FirebaseUser=等待_firebaseAuth.currentUser();
打印(密码);
user.updatePassword(密码)。然后((){
打印(“成功更改密码”);
}).catchError((错误){
打印(“无法更改密码”+错误.toString());
});
}
它打印选择的新密码和“成功更改密码”,所以一切都应该很好,但当我尝试注销并再次登录时,是旧密码起作用,而不是新密码


有什么建议吗?

可能是重复的,我不这么认为。现在支持它,并且在更改密码之前重新验证用户。
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("Your password changed Succesfully ");
    }).catchError((err){
      print("You can't change the Password" + err.toString());
      //This might happen, when the wrong password is in, the user isn't found, or if the user hasn't logged in recently.
    });
  }