feat(auth): mark test accounts in login requests
This commit is contained in:
@@ -8,7 +8,7 @@ import type { FetchHook } from "ofetch";
|
||||
import { ApiPath } from "../../../data/services/api/api_path";
|
||||
import { ApiError, ErrorCode } from "../../../data/services/api/api_result";
|
||||
import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
||||
import { deviceIdentifier, Result } from "@/utils";
|
||||
import { AppEnvUtil, deviceIdentifier, Result } from "@/utils";
|
||||
|
||||
/**
|
||||
* 不需要 auth token 刷新的路径
|
||||
@@ -105,7 +105,7 @@ async function refreshGuestToken(baseUrl: string): Promise<void> {
|
||||
const response = await fetch(`${baseUrl}${ApiPath.guestLogin}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ deviceId }),
|
||||
body: JSON.stringify(withTestAccountFlag({ deviceId })),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -125,6 +125,12 @@ async function refreshGuestToken(baseUrl: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function withTestAccountFlag<T extends Record<string, unknown>>(
|
||||
payload: T,
|
||||
): T & { isTestAccount: boolean } {
|
||||
return { ...payload, isTestAccount: !AppEnvUtil.isProduction() };
|
||||
}
|
||||
|
||||
/**
|
||||
* 401 → 刷新 token 并重试
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user