yikart/AiToEarn · error · AppHttpException
40023
40023
Error message
用户手机号状态有误
What it means
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.
Source
Thrown at project/aitoearn-electron/server/src/user/userPop.controller.ts:35
@ApiTags('用户推广')
@Controller('user/pop')
export class UserPopController {
constructor(private readonly userService: UserService) {}
@ApiOperation({
summary: '生成并获取自己的推广码',
})
@Get('code')
async generateUsePopularizeCode(@GetToken() token: TokenInfo) {
const userInfo = await this.userService.getUserInfoById(token.id);
if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);
if (userInfo.status === UserStatus.STOP)
throw new AppHttpException(ErrHttpBack.err_no_power_login);
if (!!userInfo.popularizeCode) return userInfo.popularizeCode;
if (!token.phone)
throw new AppHttpException(ErrHttpBack.err_user_phone_null);
const res = await this.userService.generateUsePopularizeCode(
token.id,
token.phone,
);
return res;
}
}
View on GitHub (pinned to d3aa8bea5b)
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.
Example fix
// before
if (userInfo.status === UserStatus.STOP)
throw new AppHttpException(ErrHttpBack.err_no_power_login);
// after (client-side pre-check)
if (userInfo.status === UserStatus.STOP) {
showToast('账号已被停用,无法生成推广码');
return;
} Defensive patterns
Strategy: validation
Validate before calling
if (userInfo?.status === UserStatus.STOP) {
// block the call before invoking the API
return
}
await api.generateUsePopularizeCode() Type guard
function isAccountActive(u: { status: UserStatus } | null | undefined): boolean {
return !!u && u.status !== UserStatus.STOP
} Try / catch
try {
const code = await api.generateUsePopularizeCode()
}
catch (e) {
if (e?.code === 40023) showToast('账号已被停用')
else throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- userId is required
- ResponseCode.ChannelAccountNotAuthorized
- ChannelAuthRefreshTokenMissing
- ChannelAccessTokenFailed
- ChannelRefreshTokenFailed
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/392af362351fc5fe.
Report an issue: GitHub.