0

Try to make a login system with firebase .When I sign Up , data store firebase and give me verification mail,its useless . I need first give me mail when I confirmed then data store firebase .It's perfectly work if I can't use verification ,perfectly store data and work fine .when i use verification its give me email and store data same time its not waiting my confirmation..

const SignUp = () => {


    const [user, setUser] = useState({

        isSignIn: false,
        name: '',
        email: '',
        password: '',
        confirmPassword: '',
        error: '',
        passwordError: '',
        success: false


    })


    //check function  password  & confirm password equal or not 

    const isPasswordConfirmed = (password, confimPassword) => {

        if (password && confimPassword && password === confimPassword) return true;
        return false;
    }


    const handleSubmit = (event) => {
        event.preventDefault()

        if (!isPasswordConfirmed(user.password, user.password_confirm)) {

            let newuser = { ...user }
            newuser.passwordError = "password not matching"
            setUser(newuser)

            return;
        }

    //   user.sendEmailVerification()
               
      



      const newname=  firebase.auth().createUserWithEmailAndPassword(user.email, 
 user.password)
    
         
            .then((userCredential) => {
                // Signed in 

              
               
                var user = userCredential.user;
                
                 user.sendEmailVerification()  //mail verification firebase 
              
                let newuser = { ...user }
                newuser.error = ""
                
                setUser(newuser)

                // UserInfoPass(user.name)

                // ...
            })
            
            .catch((error) => {
                var errorCode = error.code;
                var errorMessage = error.message;
                user.isSignIn = false

                let newuser = { ...user }
                newuser.error = errorMessage
                setUser(newuser)




            });



    }
Neel Boy
  • 27
  • 2
  • 6

1 Answers1

0

This has been covered frequently before: Firebase Authentication doesn't require email verification before signing the user in. Instead you can check the user's verification status in your application code (both front-end code, back-end code, and in Firebase's security rules), to ensure they can only use the app once they've verified their email address.

Alternatively, you can use an email link to sign in to combine the email verification and authentication in a single step.

For more on this see:

And many more from this search

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • This answer is really useful.Thanks for taking the time to contribute an answer.You are really great. – Neel Boy Aug 15 '21 at 15:39