File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
'use server';
import { redirect } from 'next/navigation';
import { revalidatePath } from 'next/cache';
import { deleteSession, readSessionToken } from '@/lib/auth/session';
/**
* 로그아웃 Server Action — 자기 세션을 파기하는 동작이라 `verifySession()`의 전제(관리자 조회)가
* 성립하지 않는다. 토큰 존재 여부만 확인해 이미 로그아웃된 상태의 중복 호출도 안전하게 처리한다.
*/
export async function logout(): Promise<void> {
const token = await readSessionToken();
if (!token) {
redirect('/login');
}
await deleteSession();
revalidatePath('/', 'layout');
redirect('/login');
}