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

This commit is contained in:
2026-11-03 15:11:33 +09:00
parent 7f9cbe4f09
commit dd4fc8f230
6 changed files with 134 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import { AuthSessionGate } from "@/components/app-shell/AuthSessionGate";
import AppMainLayout from "@/components/app-shell/AppMainLayout";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
@@ -31,8 +32,8 @@ export default async function MainLayoutWrapper({
}
return (
<AppMainLayout initialFontSize={initialFontSize}>
<AuthSessionGate><AppMainLayout initialFontSize={initialFontSize}>
{children}
</AppMainLayout>
</AppMainLayout></AuthSessionGate>
);
}

View File

@@ -0,0 +1,22 @@
import { NextResponse } from "next/server";
import { errorToResponse } from "@kri/common/http";
import { createContactApi } from "@/lib/http-server";
import {isLoginUser} from "@/lib/auth-user";
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 createContactApi();
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;
}
}