1
votes

After creating user with email and password I am calling #sendEmailVerification(). What I know is that Firebase create user with email and password first and then send verification mail to that user.

Tthis works fine if the user is accessible to that mail id and verify the mail which makes user.isEmailVerified = true.

But, if user fails to verify mail or he/she can not access the provided mail, the email Id will get locked because the account is created with that email id.

My question is that what to do when user fails to verify email?

1
Maybe remind the user that they need to verify before using the application with a simple Toast messageJanwilx72
yes give an istruction that create user with an accessible mail idNazim ch
Yes i already show toast message . But if user dont want to verify then in that case their email id get locked in firebase. What i need is that if user dont verify then delete their account.Sagar Raut

1 Answers

1
votes

If you record the fact that a user registered in the Firebase Database, you can use the Admin SDK to regularly clean out users with unverified email addresses.

See https://firebase.google.com/docs/auth/admin/manage-users#delete_a_user

admin.auth().getUser(uid)
  .then(function(userRecord) {
    if (!userRecord.emailVerified) {
      admin.auth().deleteUser(uid)
        .then(function() {
          console.log("Successfully deleted user");
        })
        .catch(function(error) {
          console.log("Error deleting user:", error);
        });
    }
  })
  .catch(function(error) {
    console.log("Error fetching user data:", error);
  });