yikart/AiToEarn · error · AppHttpException

ErrHttpBack.err_user_code_nohad

ErrHttpBack.err_user_code_nohad

Error message

err_user_code_nohad

What it means

After optional invite validation, loginByPhoneCode verifies the SMS code via verifyPhoneCode unless NODE_ENV=development or the code equals the backdoor value 'yika888666'; a failed verification throws err_user_code_nohad.

Source

Thrown at project/aitoearn-electron/server/src/user/userLogin.controller.ts:94

  ) {
    const { phone, code, inviteCode } = loginInfo;

    // 邀请码验证
    if (!!inviteCode) {
      const inviteUserInfo =
        await this.userService.getUserByPopularizeCode(inviteCode);
      if (!inviteUserInfo)
        throw new AppHttpException(ErrHttpBack.err_user_pop_code_null);
    }

    // 验证短信验证码
    if (process.env.NODE_ENV !== 'development' && code !== 'yika888666') {
      const res = await this.loginService.verifyPhoneCode(
        phone,
        code,
        LoginTypeCacheKey.Code,
      );
      if (!res) throw new AppHttpException(ErrHttpBack.err_user_code_nohad);
    }

    let userInfo: User = await this.userService.getUserInfoByPhone(phone);
    if (!userInfo) {
      const newUser = new NewUserByPhone(phone);
      if (!!inviteCode) newUser.inviteCode = inviteCode;
      userInfo = await this.userService.createUser(newUser);
    }

    if (userInfo.status === UserStatus.STOP)
      throw new AppHttpException(ErrHttpBack.err_no_power_login);

    const token = await this.authService.generateToken(userInfo);
    const TokenInfo = await this.authService.decodeToken(token);

    return {
      token,
      exp: TokenInfo.exp,

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Request a new code and use the latest SMS within 5 minutes
  2. Double-check the 6 digits before submitting
  3. Confirm environment: in development the check is skipped (or master code 'yika888666' works)
  4. Check Redis availability if codes fail immediately after issuance

Example fix

// before
await loginApi.loginByPhoneCode(phone, expiredCode, invite);
// after
await loginApi.loginByPhoneCode(phone, freshCode, invite); // code from latest SMS, <5min old
Defensive patterns

Strategy: validation

Validate before calling

const stored = await redisService.get(`login:code:${phone}`);
if (!stored) await loginService.postPhoneLoginCode(phone); // no/expired code — resend

Try / catch

try {
  await loginApi.loginByPhoneCode(phone, code, invite);
} catch (e) {
  if (e.response?.message === 'err_user_code_nohad') {
    await loginService.postPhoneLoginCode(phone); // resend and retry once
  }
}

Prevention

When it happens

Trigger: Login with a phone code that is wrong, expired (>5 min), or superseded by a newer code while not in development mode and not using the master code.

Common situations: Expired code after the 60*5s TTL; entering an old code after re-requesting; typo in the 6-digit code; Redis restarted losing cached codes; production where SMS never arrived.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/7c22aca5335d6aac. Report an issue: GitHub.