Skip to content

Commit 5a993b2

Browse files
committed
fix(50): 로그인 실패 시 UnauthorizedException 처리 및 에러 메시지 개선
1 parent 5f7e73c commit 5a993b2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/app/api/auth/login/route.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type NextRequest, NextResponse } from "next/server";
33
import { postLogin } from "@/app/_api/auth/auth.api";
44
import { TOKEN_TIMES } from "@/constants/time.constants";
55
import { type ApiError } from "@/lib/api";
6+
import { UnauthorizedException } from "@/lib/exceptions";
67
import { getSessionFromServer } from "@/lib/session";
78

89
/**
@@ -48,10 +49,10 @@ export const POST = async (req: NextRequest) => {
4849
return NextResponse.json(data.information);
4950
} catch (error) {
5051
console.error("Login failed:", error);
51-
// TODO: 에러 처리 세분화
52+
5253
return NextResponse.json<ApiError>(
53-
{ errorMessage: "인증에 실패했습니다." },
54-
{ status: 401 }
54+
{ errorMessage: "로그인에 실패했습니다." },
55+
{ status: error instanceof UnauthorizedException ? 401 : 400 }
5556
);
5657
}
5758
};

0 commit comments

Comments
 (0)