当我运行应用程序并尝试更改电子邮件时,Toast 为“useremail 未更新”:
这是错误
电子邮件未更新 com.google.firebase.auth.FirebaseAuthException:不允许此操作。这可能是因为此 Firebase 项目禁用了给定的登录提供程序。在 Firebase 控制台的“身份验证”部分的“登录方法”选项卡下启用它。 [ 更改电子邮件之前请验证新电子邮件。 ] 在 com.google.android.gms.internal.firebase-auth-api.zzach.zza(com.google.firebase:firebase-auth@@23.0.0:39) 在 com.google.android.gms.internal.firebase-auth-api.zzadg.zza(com.google.firebase:firebase-auth@@23.0.0:21) 在 com.google.android.gms.internal.firebase-auth-api.zzacz.zza(com.google.firebase:firebase-auth@@23.0.0:35) 在 com.google.android.gms.internal.firebase-auth-api.zzadb.zza(com.google.firebase:firebase-auth@@23.0.0:75) 在 com.google.android.gms.internal.firebase-auth-api.zzacf.zza(com.google.firebase:firebase-auth@@23.0.0:46) 在 com.google.android.gms.internal.firebase-auth-api.zzaad.zza(com.google.firebase:firebase-auth@@23.0.0:3) 在 com.google.android.gms.internal.firebase-auth-api.zzyu.zza(com.google.firebase:firebase-auth@@23.0.0:2) 在 com.google.android.gms.internal.firebase-auth-api.zzadp.zza(com.google.firebase:firebase-auth@@23.0.0:15) 在 com.google.android.gms.internal.firebase-auth-api.zzadp.zza(com.google.firebase:firebase-auth@@23.0.0:64) 在 com.google.android.gms.internal.firebase-auth-api.zzacw.zza(com.google.firebase:firebase-auth@@23.0.0:105) 在 com.google.android.gms.internal.firebase-auth-api.zzyl.zza(com.google.firebase:firebase-auth@@23.0.0:43) 在 com.google.android.gms.internal.firebase-auth-api.zzyr.zza(com.google.firebase:firebase-auth@@23.0.0:8) 在 com.google.android.gms.internal.firebase-auth-api.zzadp.zza(com.google.firebase:firebase-auth@@23.0.0:20) 在 com.google.android.gms.internal.firebase-auth-api.zzadp.zza(com.google.firebase:firebase-auth@@23.0.0:64) 在 com.google.android.gms.internal.firebase-auth-api.zzacw.zza(com.google.firebase:firebase-auth@@23.0.0:54) 在 com.google.android.gms.internal.firebase-auth-api.zzyl.zza(com.google.firebase:firebase-auth@@23.0.0:35) 在 com.google.android.gms.internal.firebase-auth-api.zzaad.zza(com.google.firebase:firebase-auth@@23.0.0:9) 在 com.google.android.gms.internal.firebase-auth-api.zzyl.zza(com.google.firebase:firebase-auth@@23.0.0:90) 在 com.google.android.gms.internal.firebase-auth-api.zzyl.zzb(com.google.firebase:firebase-auth@@23.0.0:58) 在 com.google.android.gms.internal.firebase-auth-api.zzaci.zzb(com.google.firebase:firebase-auth@@23.0.0:17) 在 com.google.android.gms.internal.firebase-auth-api.zzabx.zza(com.google.firebase:firebase-auth@@23.0.0:15) 在 com.google.android.gms.internal.firebase-auth-api.zzadi.run(com.google.firebase:firebase-auth@@23.0.0:2) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 在 com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47) 在 com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) 在 java.lang.Thread.run(Thread.java:761)
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// Get auth credentials from the user for re-authentication
AuthCredential credential = EmailAuthProvider
.getCredential(user.getEmail(), "123456789"); // Current Login Credentials \\
// Prompt the user to re-provide their sign-in credentials
user.reauthenticate(credential)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Toast.makeText(ProfilePage.this, "User re-authenticated.", Toast.LENGTH_SHORT).show();
//Now change your email address \\
//----------------Code for Changing Email Address----------\\
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.updateEmail("[email protected]")
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(ProfilePage.this, "User email address updated.", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(ProfilePage.this, "useremail not updated", Toast.LENGTH_SHORT).show();
}
}
});
//----------------------------------------------------------\\
}
});
您收到以下错误:
不允许进行此操作。这可能是因为此 Firebase 项目禁用了给定的登录提供程序。
因为您没有在 Firebase 控制台内启用使用电子邮件和密码登录 Firebase。要解决此问题,请在 Firebase 控制台中“身份验证”部分的登录方法选项卡下启用它。因此,请点击“添加新提供商”,然后选择“电子邮件/密码”并启用它。