我正在开发一个基于 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);
}
使用此重置密码:
Future<void> resetpassword (String email) async {
await _auth.sendPasswordResetEmail(email: email);
}