You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase认证模拟器报错“Do not allow login the email”原因及函数解析

问题描述

使用Firebase认证与数据库模拟器运行带邮箱密码认证功能的项目时,用虚构邮箱注册抛出以下错误:

Uncaught (in promise) Error: Do not allow login the email
    at FirebaseAuthenticator.<anonymous> (authenticator.ts:53:13)
    at Generator.next (<anonymous>)
    at fulfilled (index.tsx:132:3)

检查authenticator.ts代码后,发现并非模拟器判定邮箱无效,相关代码如下:

// authenticator.ts
async signUp(name: string, email: string, password: string): Promise<UserId> {
    await this.checkToAllowSigningUserWith(email);

    try {
      const auth = await createUserWithEmailAndPassword(this.auth, email, password);
      const uid = auth.user.uid;

      const userId = createUserId(uid);
      const user = createUser({ id: userId, name, joinedGames: [] });
      this.userRepository.save(user);

      return userId;
    } catch (e) {
      console.error(e);
      throw e;
    }
  }

  private async checkToAllowSigningUserWith(email: string) {
    const definedUser = await get(ref(this.database, "defined-users"));
    const mails = (definedUser.val() as string[] | null) || [];
    const existsMail = mails.some((v) => v === email);

    if (!existsMail) {
      throw new Error("Do not allow login the email");
    }
  }

请问checkToAllowSigningUserWith函数的作用是什么?何时会抛出该错误?


解答

checkToAllowSigningUserWith函数的作用

这是项目自定义的邮箱白名单校验逻辑,并非Firebase模拟器自带功能。它会从Firebase数据库的defined-users节点读取预先配置的允许注册邮箱列表,校验当前待注册的邮箱是否属于该列表。

抛出错误的时机

当待注册的邮箱不在defined-users节点存储的邮箱列表内时,该函数就会抛出Do not allow login the email错误。你遇到的问题是因为虚构邮箱不在项目预设的白名单中,和Firebase模拟器本身的邮箱有效性判定无关。

内容的提问来源于stack exchange,提问作者lipsum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 17:17:49