yikart/AiToEarn · error · AppHttpException
ErrHttpBack.err_user_no_had
ErrHttpBack.err_user_no_had
Error message
err_user_no_had
What it means
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.
Source
Thrown at project/aitoearn-electron/server/src/user/user.controller.ts:63
) {
const userInfo = await this.userService.getUserInfoById(token.id);
for (const key in body) {
if (Object.prototype.hasOwnProperty.call(body, key)) {
userInfo[key] = body[key];
}
}
this.userService.updateUser(token.id, userInfo);
return userInfo;
}
@ApiOperation({ description: '用户注销', summary: '用户注销' })
@ApiResponse({ status: 200, type: UserResDto })
@Delete('del')
async del(@GetToken() token: TokenInfo) {
const userInfo = await this.userService.getUserInfoById(token.id);
if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);
const res = await this.userService.deleteUser(userInfo);
return res;
}
@ApiOperation({
summary: '用户更新自己的电话号码',
description: '和手机验证码登录使用同一个验证码',
})
@Put('updatePhone')
async updatePhone(
@GetToken() token: TokenInfo,
@Body() body: LoginByPhoneDto,
) {
const { phone, code } = body;
const res = await this.loginService.verifyPhoneCode(
phone,View on GitHub (pinned to d3aa8bea5b)
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
Example fix
// before
await userApi.del(); // throws if account already gone
// after
try { await userApi.del(); } catch (e) {
clearLocalToken(); // account already deleted or invalid — sign out
} Defensive patterns
Strategy: try-catch
Validate before calling
const me = await userApi.getInfo();
if (!me) { clearLocalToken(); return; } // account gone; skip del Try / catch
try {
await userApi.del();
} catch (e) {
if (e.response?.message === 'err_user_no_had') clearLocalToken();
} Prevention
- 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
When it happens
Trigger: DELETE /user/del with a JWT whose token.id no longer maps to a user (account already deleted, DB wiped, or environment mismatch).
Common situations: 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.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/30bc708176c7166a.
Report an issue: GitHub.