Firebase email verification at SignUp

后端 未结 1 1235
梦如初夏
梦如初夏 2021-01-24 06:59

How should I go about verifying an email address prior to the user signing up with Firebase? I know that an email address is verified with .sendEmailVerification,

相关标签:
1条回答
  • 2021-01-24 07:22

    You can't verify the email prior to sign up with Firebase Auth. Email verification is not always required. This is why Firebase Auth provides it as a method on the user. Some applications do not require email verification on sign-up, others may make it optional, others may offer limited access to unverified users, etc.

    If you want to require users to be verified before accessing your app content, you can either: enforce that via Firebase rules, eg: ".read": "auth.token.email_verified === true"

    Or, if you are using your own backend, use the Firebase Admin SDK, https://firebase.google.com/docs/auth/admin/verify-id-tokens:

    admin.auth().verifyIdToken(idToken).then(decodedToken => {
      if (decodedToken.email_verified) {
        // Email verified. Grant access.
      } else {
        // Email not verified. Ask user to verify email.
      }
    });
    
    0 讨论(0)
提交回复
热议问题