When i deleted user from Realtime Database by clicking bin next to it, the user dissapear, its okay, but i can still login by his email and password, and when the login is successfull, the uuid of this user reappears when i write some values to subtables in database, but without his values defined while registering.
I thought that it should be fine after 1 hour and i could have still register him as new user, but i can't. I deleted him 2 days ago. What is wrong, how i can delete user permanently - not by blocking him?
Part of my main code:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
//textview,buttons,progress bars, etc...
mAuth = FirebaseAuth.getInstance();
forgotPassword = (TextView) findViewById(R.id.forgotPassword);
forgotPassword.setOnClickListener(this);
}
...
//Onclicks, textview value correctness etc...
progressBar.setVisibility(View.VISIBLE);
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
mAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if(user.isEmailVerified()){
// redirect to user profile
progressBar.setVisibility(View.GONE);
startActivity(new Intent(MainActivity.this, ProfileDashboard.class));
}else {
progressBar.setVisibility(View.GONE);
user.sendEmailVerification();
Toast.makeText(MainActivity.this,"Check your email to verify your account!", Toast.LENGTH_LONG).show();
}
}else{
progressBar.setVisibility(View.GONE);
Toast.makeText(MainActivity.this, "Failed to login! Please check your credentials", Toast.LENGTH_LONG).show();
}
}
});
}
}
CodePudding user response:
The Realtime Database
is not the same as Authentication
.
Deleting the user in Authentication will do the trick:
CodePudding user response:
As the mentioned comment above, deleting from Database is not same as authentication.
So to do this you may use the firebase admin SDK. You can see an example here: https://firebase.google.com/docs/auth/android/manage-users.
So basically what you can do is to delete the user from the DB, then from the Firebase Auth to avoid having that kind of issues; example:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.delete()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "User account deleted.");
}
}
});