Art*_*sky 3 javascript firebase firebase-authentication angularfire2
我可以在 Firebase 身份验证中验证电子邮件域区域吗?
例如,我只想为来自 yahoo 和 gmail 的电子邮件( @yahoo.com、@gmail.com 电子邮件)提供成功注册
ps当然我可以在客户端验证它,但这还不够
不幸的是,您无法在注册前验证电子邮件的域名(不包括客户端)。
您可以选择以下一些选项:
例如:
"rules": {
".read": "auth.token.email.endsWith('@gmail.com')",
".write": "auth.token.email.endsWith('@gmail.com')"
}
}
Run Code Online (Sandbox Code Playgroud)
或者像这样:
"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$/)"
}
}
Run Code Online (Sandbox Code Playgroud)
例如:
exports.validateUser = functions.auth.user().onCreate((user) => {
if (!user.email.matches(/.*@gmail.com$/)) {
admin.auth().updateUser(data, {
disabled: true
});
}
});
Run Code Online (Sandbox Code Playgroud)
学分: https: //firebase.google.com/docs/functions/auth-events
| 归档时间: |
|
| 查看次数: |
889 次 |
| 最近记录: |