简体   繁体   中英

Tried to create user using react firebase hook though sendEmailVerification(); added but with out verifying it create user: here is the code below:

const createUser = async () => {
    await createUserWithEmailAndPassword(email, password);
    await updateProfile({ displayName });
    await sendEmailVerification();enter code here
}

 <button onClick={ async () => await createUser() }>Create User</button>

The user will receive en email with a verification link.

Clicking this link will verify this user.

However, the user is created even without verification in the database. This is normal.

But: One can check the field emailVerified of the user object.

It should more or less look something like this, for example if the user tries to login without having the email address verified:

final credential = await 
  signInWithEmailAndPassword(email: email, password: password);

if( credential.user.emailVerified == false ) ...

You can disable user after he will create account using Firebase Functions and firebase-admin SDK. If user verify email account, you can enable his account same using Firebase Functions.

const createUser = async () => {
    await createUserWithEmailAndPassword(email, password);
    await sendEmailVerification();enter code here
    if(user.emailVerfied === true){
    await updateProfile({ displayName });
    }
    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM