重新设计状态码规范

This commit is contained in:
2026-03-05 13:44:56 +08:00
parent 8d8cee696f
commit 5ab16243bd
6 changed files with 46 additions and 33 deletions

View File

@@ -26,12 +26,12 @@ class CheckUserTokenMiddleware implements MiddlewareInterface
}
}
if (empty($token)) {
throw new ApiException('请携带 user-token', ReturnCode::MISSING_TOKEN);
throw new ApiException('请携带 user-token', ReturnCode::UNAUTHORIZED);
}
$userId = UserLogic::getUserIdFromToken($token);
if ($userId === null) {
throw new ApiException('user-token 无效或已过期', ReturnCode::TOKEN_TIMEOUT);
throw new ApiException('user-token 无效或已过期', ReturnCode::TOKEN_INVALID);
}
$request->user_id = $userId;