{"record":{"id":"392af362351fc5fe","repo":"yikart/AiToEarn","slug":"40023","errorCode":"40023","errorMessage":"用户手机号状态有误","messagePattern":"用户手机号状态有误","errorType":"error_code","errorClass":"AppHttpException","httpStatus":200,"severity":"error","filePath":"project/aitoearn-electron/server/src/user/userPop.controller.ts","lineNumber":35,"sourceCode":"@ApiTags('用户推广')\n@Controller('user/pop')\nexport class UserPopController {\n  constructor(private readonly userService: UserService) {}\n\n  @ApiOperation({\n    summary: '生成并获取自己的推广码',\n  })\n  @Get('code')\n  async generateUsePopularizeCode(@GetToken() token: TokenInfo) {\n    const userInfo = await this.userService.getUserInfoById(token.id);\n    if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);\n    if (userInfo.status === UserStatus.STOP)\n      throw new AppHttpException(ErrHttpBack.err_no_power_login);\n\n    if (!!userInfo.popularizeCode) return userInfo.popularizeCode;\n\n    if (!token.phone)\n      throw new AppHttpException(ErrHttpBack.err_user_phone_null);\n    const res = await this.userService.generateUsePopularizeCode(\n      token.id,\n      token.phone,\n    );\n    return res;\n  }\n}\n","sourceCodeStart":17,"sourceCodeEnd":43,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/user/userPop.controller.ts#L17-L43","documentation":" thrown by generateUsePopularizeCode when a user whose account status is UserStatus.STOP attempts to obtain a referral/popularize code. The guard short-circuits blocked accounts before issuing any code. It is an intentional business-rule rejection, not an unexpected fault.","triggerScenarios":"Calling generateUsePopularizeCode (or the endpoint that exposes it) with a valid token whose userInfo.status === UserStatus.STOP, i.e. the account has been disabled/banned.","commonSituations":"Admins disabling accounts for abuse or non-payment; users with banned/stopped accounts trying to log in on an old cached session and access the referral feature; test accounts flipped to STOP status in staging.","solutions":["Unblock the account: change the user's status back to an active value in the admin panel or users table.","Verify with an active test account that the request works, confirming the error is status-driven.","Clear stale tokens after reactivation; force re-login so userInfo is refetched fresh.","If status was never meant to be STOP, audit the admin workflow that set it."],"exampleFix":"// before\nif (userInfo.status === UserStatus.STOP)\n  throw new AppHttpException(ErrHttpBack.err_no_power_login);\n// after (client-side pre-check)\nif (userInfo.status === UserStatus.STOP) {\n  showToast('账号已被停用，无法生成推广码');\n  return;\n}","handlingStrategy":"validation","validationCode":"if (userInfo?.status === UserStatus.STOP) {\n  // block the call before invoking the API\n  return\n}\nawait api.generateUsePopularizeCode()","typeGuard":"function isAccountActive(u: { status: UserStatus } | null | undefined): boolean {\n  return !!u && u.status !== UserStatus.STOP\n}","tryCatchPattern":"try {\n  const code = await api.generateUsePopularizeCode()\n}\ncatch (e) {\n  if (e?.code === 40023) showToast('账号已被停用')\n  else throw e\n}","preventionTips":["Check user status in the UI before exposing referral features.","Handle 401/40023 responses globally by forcing logout for stopped accounts.","After account reactivation, force a fresh login to refresh cached userInfo."],"tags":["auth","account-status","business-rule"],"backgroundTag":"account-disabled","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}