简体   繁体   中英

How to tell if a user clicked on a confirmation email sent with user.sendEmailVerification() in jsx

I have this code for send a email, but I do not know how to wait for the answer (if confirm or not) because no matter if it confirms or not, it registers it

  handleSubmit = (e) => {
e.preventDefault()
firebaseAuth().createUserWithEmailAndPassword(this.email.value, this.pw.value)
.then(function(user) {
    user.sendEmailVerification()
}).then(function () {
    alert("User signup success");
}).catch(function (error) {
  var errorCode = error.code;
  var errorMessage = error.message;
  if (errorCode === 'auth/wrong-password') {

          alert('Wrong password.');
      }
  else if(errorCode=='auth/email-already-in-use'){
    alert("esa cuenta de correo ya esta en uso");
  }
  else {
          alert(errorMessage);
        }
        console.log(error);
      });

}

I don't know much about reactjs or fire base. But what you need to do is before you send the email create a unique id for every user when the submit the sign up form. In the email you genarate you need to add a button(link) to click if user need to get registered to the site. that link should redirect to your site with the id you have saved ex https://yoursite.com/signup-action?id=QSE$#@$WDVVDsfdsfew543

now when user click this you can get the id from the url and check if it is in the database and who is the user and can update the table to activate the user. That is how you know that the user has clicked the email.. then ask the user to log in

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