简体   繁体   English

如何判断用户是否单击了jsx中与user.sendEmailVerification()一起发送的确认电子邮件

[英]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. 我对reactjs或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. 但是您需要做的是在发送电子邮件之前,在提交注册表单时为每个用户创建一个唯一的ID。 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 该链接应使用您之前保存的ID重定向到您的网站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. 现在,当用户单击此按钮时,您可以从URL获取ID,并检查它是否在数据库中以及用户是谁,并且可以更新表以激活用户。 That is how you know that the user has clicked the email.. then ask the user to log in 这就是您知道用户单击电子邮件的方式。然后要求用户登录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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