Flutter firebase 重新验证用户不起作用

问题描述 投票:0回答:1

我正在开发一个基于 firebase 身份验证(电子邮件/密码)的项目。 我需要添加更改密码选项。当尝试更改凭据时显示错误。

错误“密码无效或用户没有密码。”

我已经尝试过这个代码。

  FirebaseAuth auth = FirebaseAuth.instance;

  checkUser() {
    if (auth.currentUser != null) {
      print(auth.currentUser.email);
      changePass();
    } else {
      print("user not found");
    }
  }

  void changePass() async {
    print("clicked");
    EmailAuthCredential credential =
        EmailAuthProvider.credential(email: auth.currentUser.email, password: "Password@3221");

    await auth.currentUser.reauthenticateWithCredential(credential);
  }

enter image description here

flutter firebase-authentication
1个回答
1
投票

使用此重置密码:

Future<void> resetpassword (String email) async {
  await _auth.sendPasswordResetEmail(email: email);
}
© www.soinside.com 2019 - 2024. All rights reserved.