更新时间:2023-12-05 23:03:16
您无法在注册 Firebase Auth 之前验证电子邮件.电子邮件验证并不总是需要的.这就是 Firebase Auth 将其作为用户方法提供的原因.某些应用程序在注册时不需要电子邮件验证,其他应用程序可能将其设为可选,其他应用程序可能会为未经验证的用户提供有限的访问权限等.
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.
如果您想要求用户在访问您的应用内容之前进行验证,您可以:通过 Firebase 规则强制执行,例如:".read": "auth.token.email_verified === true"
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"
或者,如果您使用自己的后端,请使用 Firebase Admin SDK,https://firebase.google.com/docs/auth/admin/验证 ID 令牌:
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.
}
});