diff --git a/apps/cs/src/entities/auth/api/auth-service.ts b/apps/cs/src/entities/auth/api/auth-service.ts index cf7281ff9..93c0bc0bb 100644 --- a/apps/cs/src/entities/auth/api/auth-service.ts +++ b/apps/cs/src/entities/auth/api/auth-service.ts @@ -4,35 +4,15 @@ import { CLAIM_NAME, ENDPOINT, } from "@/shared/config"; -import { - type AuthPayload, - type AuthService, - getRemainingMs, -} from "@common/auth"; +import { type AuthPayload, type AuthService } from "@common/auth"; import { clearDeviceId, getOrCreateDeviceId } from "../lib/device-id"; import { clearRefreshTimer, setToken, - setupRefreshTimer, tokenManager, } from "../lib/token-manager"; -function resolveLoginError(message: string | undefined): string { - switch (message) { - case "Invalid Credentials": - return "아이디와 비밀번호가 일치하지 않습니다."; - case "User not found": - return "존재하지 않는 아이디입니다."; - case "User is not active": - return "활성화되지 않은 계정입니다."; - case "User is not verified": - return "이메일 인증이 필요합니다."; - default: - return message ?? "로그인에 실패했습니다."; - } -} - async function login(payload: AuthPayload): Promise { const response = await fetch(`/api/proxy${ENDPOINT.USER_SERVICE.LOGIN}`, { method: "POST", @@ -45,12 +25,8 @@ async function login(payload: AuthPayload): Promise { const data = await response.json(); - if (!response.ok) { - throw new Error(resolveLoginError(data?.message)); - } - - const accessToken = data[ACCESS_TOKEN] as string | undefined; - const tokenId = data[AUTH_USER_ID] as string | undefined; + const accessToken = data[ACCESS_TOKEN]; + const tokenId = data[AUTH_USER_ID]; if (!accessToken || !tokenId) { throw new Error("인증 토큰을 받지 못했습니다."); @@ -59,10 +35,10 @@ async function login(payload: AuthPayload): Promise { setToken(CLAIM_NAME, accessToken); setToken(AUTH_USER_ID, tokenId); - const remainingMs = getRemainingMs(accessToken); - if (remainingMs > 0) { - setupRefreshTimer(silentRefresh, remainingMs); - } + // const remainingMs = getRemainingMs(accessToken); + // if (remainingMs > 0) { + // setupRefreshTimer(silentRefresh, remainingMs); + // } } async function silentRefresh(): Promise { @@ -84,8 +60,8 @@ async function silentRefresh(): Promise { throw new Error(data?.message ?? "토큰 갱신에 실패했습니다."); } - const accessToken = data[ACCESS_TOKEN] as string | undefined; - const tokenId = data[AUTH_USER_ID] as string | undefined; + const accessToken = data[ACCESS_TOKEN]; + const tokenId = data[AUTH_USER_ID]; if (!accessToken || !tokenId) { throw new Error("갱신된 인증 토큰을 받지 못했습니다."); @@ -94,10 +70,10 @@ async function silentRefresh(): Promise { setToken(CLAIM_NAME, accessToken); setToken(AUTH_USER_ID, tokenId); - const remainingMs = getRemainingMs(accessToken); - if (remainingMs > 0) { - setupRefreshTimer(silentRefresh, remainingMs); - } + // const remainingMs = getRemainingMs(accessToken); + // if (remainingMs > 0) { + // setupRefreshTimer(silentRefresh, remainingMs); + // } } catch (error) { console.error( `[silentRefresh] Failed at ${new Date().toISOString()}`,