관리자 계정 설정, 관리자 페이지 작업1
This commit is contained in:
35
lib/auth.ts
Normal file
35
lib/auth.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 관리자 인증 유틸리티 함수
|
||||
*/
|
||||
|
||||
/**
|
||||
* 관리자 로그인 상태 확인
|
||||
* @returns 관리자 로그인 여부
|
||||
*/
|
||||
export function isAdminLoggedIn(): boolean {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return localStorage.getItem('isAdminLoggedIn') === 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 인증 체크 및 리다이렉트
|
||||
* 인증되지 않은 경우 로그인 페이지로 이동
|
||||
*/
|
||||
export function requireAdminAuth(): boolean {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isAdmin = isAdminLoggedIn();
|
||||
|
||||
if (!isAdmin) {
|
||||
// 관리자 인증되지 않은 경우 로그인 페이지로 리다이렉트
|
||||
window.location.href = '/login';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user