首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Firebase:如何手动将Google登录验证器限制为特定的电子邮件地址?

Firebase:如何手动将Google登录验证器限制为特定的电子邮件地址?
EN

Stack Overflow用户
提问于 2021-09-14 13:11:22
回答 1查看 118关注 0票数 0

我如何才能在我的React.js web应用程序上仅针对特定的电子邮件地址使用谷歌登录?

我不希望限制特定的域,但告诉验证器,只有特定的电子邮件地址可以注册或登录,并为所有其他地址抛出一个错误。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-14 13:18:25

Firebase身份验证中没有内置任何内容来限制登录到特定的域或电子邮件地址。但是,如果您升级到Google Cloud Identity (付费升级),则可以使用customize the authentication flow with a blocking Cloud Function

基于该链接中的一个示例:

代码语言:javascript
复制
// Import the Cloud Auth Admin module.
const gcipCloudFunctions = require('gcip-cloud-functions');
// Initialize the Auth client.
const authClient = new gcipCloudFunctions.Auth();
// Http trigger with Cloud Functions.
exports.beforeCreate = authClient.functions().beforeCreateHandler((user, context) => {
  // If the user is authenticating within a tenant context, the tenant ID can be determined from
  // user.tenantId or from context.resource, eg. 'projects/project-id/tenant/tenant-id-1'
  // Only this one user can sign up.
  if (user.email !== 'user@acme.com') {
    throw new gcipCloudFunctions.https.HttpsError('invalid-argument', `Unauthorized email "${user.email}"`);
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69178447

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档