Firebase email verification workflow

前端 未结 2 1250
小蘑菇
小蘑菇 2021-01-29 03:31

I have a simple input box asking for users emails.

I want them to input something, for me to check it is a string, and then send a verification email to their email addr

相关标签:
2条回答
  • 2021-01-29 03:50

    I have a simple input box asking for users emails.

    I want them to input something, for me to check it is a string, and then send a verification email to their email address entered.

    Then once verified within users mail client and the link is clicked, I want the user to be added to my Firebase users.

    I do not think Firebase works that way. Unless the user is registered, you cannot send a verification email to an arbitrary email address. The sendEmailVerification method works on a currentUser.

    According to the docs:

    You can send an address verification email to a user with the sendEmailVerification method

    Now, to your snippet, aren't you simply trying to take a user input and save it to the database? With the recent SDK, you can try this, as per docs

    ....
    
    var database = firebase.database();
    
    function signup(formObj) {
        // Store emails to firebase
        database.ref('signups')
          .push({
             email: formObj.email.value,
          })
          .then(function(res) {
             console.log(res)
             // call whatever callback you want here
          })
          .catch( .... )
    }
    
    0 讨论(0)
  • 2021-01-29 03:53

    FYI if you are using Firebase email verification think about testing it during your end-to-end or smoke tests.

    Use a service like emaile2e.com to generate random email addresses during a test which you can send and receive from. That way you can verify users during a test programmatically.

    0 讨论(0)
提交回复
热议问题