[英]Can I validate email's domain zone in Firebase Authentication?
Can I validate email domain zone in Firebase Authentication? 我可以在Firebase身份验证中验证电子邮件域区域吗?
For example, I want to give success registration just for an email from yahoo and gmail ( @yahoo.com, @gmail.com emails) 例如,我只想为来自yahoo和gmail的电子邮件( @ yahoo.com, @ gmail.com电子邮件)进行成功注册。
ps of course I can validate it in client side, but this isn't enough ps当然我可以在客户端验证它,但这还不够
Unfortunately, you can not validate the email's domain before registration (exclude the client side). 不幸的是,您无法在注册之前验证电子邮件的域(不包括客户端)。
There are some options in front of you, that you can do: 您可以执行一些选择:
For example: 例如:
"rules": {
".read": "auth.token.email.endsWith('@gmail.com')",
".write": "auth.token.email.endsWith('@gmail.com')"
}
}
or like this: 或像这样:
"rules": {
".read": "auth.token.email_verified == true && auth.token.email.matches(/.*@gmail.com$/)",
".write": "auth.token.email_verified == true && auth.token.email.matches(/.*@gmail.com$/)"
}
}
Credits: https://stackoverflow.com/a/38019847/2765346 积分: https : //stackoverflow.com/a/38019847/2765346
For example: 例如:
exports.validateUser = functions.auth.user().onCreate((user) => {
if (!user.email.matches(/.*@gmail.com$/)) {
admin.auth().updateUser(data, {
disabled: true
});
}
});
Credits: https://firebase.google.com/docs/functions/auth-events 积分: https : //firebase.google.com/docs/functions/auth-events
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.