简体   繁体   English

firebase:在注册期间发送 email 验证

[英]firebase : sending email verification during signup

I tested that user is added to database but she never receive any email: what's wrong below (took it from doc https://firebase.google.com/docs/auth/web/manage-users but something missing )我测试了该用户已添加到数据库,但她从未收到任何 email:下面出了什么问题(从文档https://firebase.google.com/docs/auth/web/manage-users 获取但缺少一些东西)

function SignUp() {
    let promise = auth.createUserWithEmailAndPassword(email.value, password.value); 
    promise.catch(
        e => alert(e.message)
    );

    var user = firebase.auth().currentUser;

    user.sendEmailVerification().then(function() {
      // Email sent.
    }).catch(function(error) {
      // An error happened.
    });
}

You're not waiting until the sign-up is complete.您不必等到注册完成。 To do that you can use the then part of the promise returned by createUserWithEmailAndPassword .为此,您可以使用createUserWithEmailAndPassword返回的 promise 的then部分。

So:所以:

let promise = auth.createUserWithEmailAndPassword(email.value, password.value); 
promise.then(
   userCredential => userCredential.user.sendEmailVerification()
}).catch(
    e => alert(e.message)
);

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

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