로그아웃을 모듈 수준 서버 액션으로 변환 (빌드 간 액션 ID 안정화)
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
import { signOut } from "@/auth";
|
||||||
|
|
||||||
|
export async function logoutAction() {
|
||||||
|
await signOut({ redirect: false });
|
||||||
|
redirect("/login");
|
||||||
|
}
|
||||||
@@ -8,9 +8,11 @@ import {
|
|||||||
LogOut,
|
LogOut,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
import { auth, signOut } from "@/auth";
|
import { auth } from "@/auth";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
|
import { logoutAction } from "./actions";
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ href: "/", label: "대시보드", icon: LayoutDashboard },
|
{ href: "/", label: "대시보드", icon: LayoutDashboard },
|
||||||
{ href: "/maestros", label: "마에스트로", icon: GraduationCap },
|
{ href: "/maestros", label: "마에스트로", icon: GraduationCap },
|
||||||
@@ -63,14 +65,7 @@ export default async function AdminLayout({
|
|||||||
관리자 ID {session.user.adminID}
|
관리자 ID {session.user.adminID}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form action={logoutAction}>
|
||||||
action={async () => {
|
|
||||||
"use server";
|
|
||||||
|
|
||||||
await signOut({ redirect: false });
|
|
||||||
redirect("/login");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button size="sm" type="submit" variant="outline">
|
<Button size="sm" type="submit" variant="outline">
|
||||||
<LogOut className="size-4" aria-hidden="true" />
|
<LogOut className="size-4" aria-hidden="true" />
|
||||||
로그아웃
|
로그아웃
|
||||||
|
|||||||
Reference in New Issue
Block a user