{"record":{"id":"30bc708176c7166a","repo":"yikart/AiToEarn","slug":"errhttpback-err-user-no-had-30bc70","errorCode":"ErrHttpBack.err_user_no_had","errorMessage":"err_user_no_had","messagePattern":"err_user_no_had","errorType":"error_code","errorClass":"AppHttpException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-electron/server/src/user/user.controller.ts","lineNumber":63,"sourceCode":"  ) {\n    const userInfo = await this.userService.getUserInfoById(token.id);\n\n    for (const key in body) {\n      if (Object.prototype.hasOwnProperty.call(body, key)) {\n        userInfo[key] = body[key];\n      }\n    }\n\n    this.userService.updateUser(token.id, userInfo);\n    return userInfo;\n  }\n\n  @ApiOperation({ description: '用户注销', summary: '用户注销' })\n  @ApiResponse({ status: 200, type: UserResDto })\n  @Delete('del')\n  async del(@GetToken() token: TokenInfo) {\n    const userInfo = await this.userService.getUserInfoById(token.id);\n    if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);\n\n    const res = await this.userService.deleteUser(userInfo);\n    return res;\n  }\n\n  @ApiOperation({\n    summary: '用户更新自己的电话号码',\n    description: '和手机验证码登录使用同一个验证码',\n  })\n  @Put('updatePhone')\n  async updatePhone(\n    @GetToken() token: TokenInfo,\n    @Body() body: LoginByPhoneDto,\n  ) {\n    const { phone, code } = body;\n\n    const res = await this.loginService.verifyPhoneCode(\n      phone,","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/user/user.controller.ts#L45-L81","documentation":"DELETE del (account self-deletion) loads the user from the authenticated token's id; if the token is valid but the underlying user row no longer exists, err_user_no_had is thrown.","triggerScenarios":"DELETE /user/del with a JWT whose token.id no longer maps to a user (account already deleted, DB wiped, or environment mismatch).","commonSituations":"Reusing an old token after account deletion; pointing the client at a different database (dev vs prod); user deleted by admin while session still active.","solutions":["Re-authenticate to get a fresh token; if the account is truly gone, stop calling user endpoints","Verify the client is pointed at the intended environment/database","If the goal was deletion, the account is already gone — clear local token and sign out"],"exampleFix":"// before\nawait userApi.del(); // throws if account already gone\n// after\ntry { await userApi.del(); } catch (e) {\n  clearLocalToken(); // account already deleted or invalid — sign out\n}","handlingStrategy":"try-catch","validationCode":"const me = await userApi.getInfo();\nif (!me) { clearLocalToken(); return; } // account gone; skip del","typeGuard":null,"tryCatchPattern":"try {\n  await userApi.del();\n} catch (e) {\n  if (e.response?.message === 'err_user_no_had') clearLocalToken();\n}","preventionTips":["Clear tokens after account deletion; never reuse old tokens","Validate the session with a lightweight GET before destructive calls","Ensure client points at the correct environment/DB"],"tags":["user","not-found","token","account-deletion"],"backgroundTag":"user-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}