我如何才能在我的React.js web应用程序上仅针对特定的电子邮件地址使用谷歌登录?
我不希望限制特定的域,但告诉验证器,只有特定的电子邮件地址可以注册或登录,并为所有其他地址抛出一个错误。
谢谢。
发布于 2021-09-14 13:18:25
Firebase身份验证中没有内置任何内容来限制登录到特定的域或电子邮件地址。但是,如果您升级到Google Cloud Identity (付费升级),则可以使用customize the authentication flow with a blocking Cloud Function。
基于该链接中的一个示例:
// 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}"`);
});https://stackoverflow.com/questions/69178447
复制相似问题