[英]Flutter FirebaseAuth: SignUp unable to handle error when the email address is used by another user
我的代碼在這里,錯誤指向-> await FirebaseAuth.instance.createUserWithEmailAndPassword( email: email.trim(), password: password.trim()); - 在下面的代碼中
Future SignUp() async {
try {
UserCredential result = await FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: email.trim(), password: password.trim());
User user = result.user;
return user;
} on FirebaseAuthException catch (e) {
print(e);
if (e.code == 'email-already-in-use') {
setState(
() // setState rebuilds the entire build by modifying the code inside it
{
error = e.toString();
EmailExists =
true; //sets the emailExists variable to 'true' and rebuild
});
}
}
}
Error: PlatformException (PlatformException(firebase_auth, com.google.firebase.auth.FirebaseAuthUserCollisionException: The email address is already in use by another account., {message: The email address is already in use by another account., additionalData: {},代碼:電子郵件已在使用},空))
嘗試不同的 email 因為您已經使用 email 和密碼創建了一個用戶
默認情況下 Firebase 身份驗證僅允許單個用戶在項目中使用特定的 email 地址進行注冊。 當第二個用戶嘗試使用相同的 email 地址注冊時,您會收到錯誤,您需要在代碼中處理該場景。 通常,您會告訴用戶 email 地址已經注冊,然后詢問他們的密碼,或者告訴他們使用另一個 email 地址。
如果您希望允許多個用戶使用相同的 email 地址注冊,您可以通過在 Z035489FF8D092741949ZE4A83241F 控制台的登錄方法選項卡中更改每個 email 地址的多個帳戶設置來啟用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.