[英]Can I validate email's domain zone in Firebase Authentication?
我可以在Firebase身份验证中验证电子邮件域区域吗?
例如,我只想为来自yahoo和gmail的电子邮件( @ yahoo.com, @ gmail.com电子邮件)进行成功注册。
ps当然我可以在客户端验证它,但这还不够
不幸的是,您无法在注册之前验证电子邮件的域(不包括客户端)。
您可以执行一些选择:
例如:
"rules": {
".read": "auth.token.email.endsWith('@gmail.com')",
".write": "auth.token.email.endsWith('@gmail.com')"
}
}
或像这样:
"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$/)"
}
}
积分: https : //stackoverflow.com/a/38019847/2765346
例如:
exports.validateUser = functions.auth.user().onCreate((user) => {
if (!user.email.matches(/.*@gmail.com$/)) {
admin.auth().updateUser(data, {
disabled: true
});
}
});
积分: https : //firebase.google.com/docs/functions/auth-events
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.