【发布时间】:2020-01-20 13:18:20
【问题描述】:
我想创建一个功能,用户可以在其中删除自己的帐户。如果用户删除了他们的帐户。他们的所有信息都将被删除,用户身份验证也将被删除。我已经创建了该功能,但不知何故在 Firebase 身份验证中,用户电子邮件没有被删除。
上图显示账号已被删除,但在认证过程中账号仍未被删除。
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder dialog = new AlertDialog.Builder(CustProfileActivity.this);
dialog.setTitle("Are you sure?");
dialog.setMessage("Deleting this account will result in completely removing your " +
" account from the system and you won't be able to access the app.");
dialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
progBar.setVisibility(View.VISIBLE);
FirebaseDatabase.getInstance().getReference().child("Customer").child(firebaseAuth.getCurrentUser().getUid()).removeValue();
currentUser.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
progBar.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "Account Deleted", Toast.LENGTH_SHORT).show();
Intent intent= new Intent(getApplicationContext(),LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
});
dialog.setNegativeButton("Dismiss", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog alertDialog = dialog.create();
alertDialog.show();
}
});
我想达到这样一个结果,即用户帐户将被删除,包括他们在 firebase 身份验证中的数据。
【问题讨论】:
-
你有什么错误吗?如果任务不成功,请登录控制台
task.getException().getMessage()。你的安全规则是什么?请将它们添加到您的问题中。 -
帐户已从 firebase 实时数据库中删除,但未从身份验证中删除
-
请回答第一条评论中的问题。
标签: java android firebase firebase-realtime-database firebase-authentication