Skip to content

Commit 9a947ec

Browse files
committed
Revert "🐛 Remove magic numbers"
This reverts commit 33069be.
1 parent 21e4544 commit 9a947ec

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

frontend/services/authService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const authService = {
3636
console.warn("Session verification failed, HTTP status code:", response.status);
3737

3838
// HTTP 401 means the token is expired or invalid
39-
if (response.status === STATUS_CODES.UNAUTHORIZED_HTTP) {
39+
if (response.status === 401) {
4040
return null;
4141
}
4242

@@ -84,7 +84,7 @@ export const authService = {
8484
try {
8585
const response = await fetch(API_ENDPOINTS.user.serviceHealth, {method: 'GET'});
8686

87-
return response.status === STATUS_CODES.SUCCESS;
87+
return response.status === 200;
8888
} catch (error) {
8989
return false;
9090
}

frontend/types/auth.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
* 认证相关类型与常量定义
33
*/
44
export const STATUS_CODES = {
5-
SUCCESS: 200,
5+
// 成功状态码
6+
SUCCESS: 200, // 成功
67

7-
UNAUTHORIZED_HTTP: 401,
8-
9-
INVALID_CREDENTIALS: 1002,
10-
TOKEN_EXPIRED: 1003,
11-
UNAUTHORIZED: 1004,
12-
INVALID_INPUT: 1006,
13-
AUTH_SERVICE_UNAVAILABLE: 1007,
14-
15-
SERVER_ERROR: 1005,
8+
// 客户端错误状态码
9+
INVALID_CREDENTIALS: 1002, // 无效的登录凭证
10+
TOKEN_EXPIRED: 1003, // Token已过期
11+
UNAUTHORIZED: 1004, // 未授权操作
12+
INVALID_INPUT: 1006, // 无效的输入参数
13+
AUTH_SERVICE_UNAVAILABLE: 1007, // 认证服务不可用
14+
15+
// 服务器错误状态码
16+
SERVER_ERROR: 1005, // 服务器内部错误
1617
};
1718

1819
// 本地存储键

0 commit comments

Comments
 (0)