261103_02_ENH: 공유 인증 사용자 정보 동기화 및 프로젝트 접근 전환 개선

This commit is contained in:
2026-11-03 15:22:19 +09:00
parent 5590cc657f
commit 5f41995c84
6 changed files with 174 additions and 45 deletions

View File

@@ -0,0 +1,22 @@
import { NextResponse } from "next/server";
import { errorToResponse } from "@kri/common/http";
import { createServerApi } from "@/lib/http-server";
import { isLoginUser } from "@/types/kart";
export async function GET(_request: Request, context: { params: Promise<{ slug?: string[] }> }) {
const { slug = [] } = await context.params;
if (slug.length !== 1 || slug[0] !== "my-info")
return NextResponse.json({ message: "Not found" }, { status: 404, headers: { "Cache-Control": "no-store" } });
try {
const api = await createServerApi();
const user = await api.get<unknown>("/auth/my-info", { cache: "no-store" });
if (!isLoginUser(user)) {
return NextResponse.json({ message: "Invalid user response" }, { status: 502, headers: { "Cache-Control": "no-store" } });
}
return NextResponse.json({ userId: user.userId, userName: user.userName, userCmpn: user.userCmpn, userTeam: user.userTeam, userRole: user.userRole }, { headers: { "Cache-Control": "no-store" } });
} catch (error) {
const response = errorToResponse(error);
response.headers.set("Cache-Control", "no-store");
return response;
}
}