권한설정 페이지 수정/student만

This commit is contained in:
2025-11-27 20:36:38 +09:00
parent 91c886298c
commit b1e2f6012c
3 changed files with 33 additions and 10 deletions

View File

@@ -2,9 +2,11 @@
'use client';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useRouter } from 'next/navigation';
import MainLogoSvg from './svgs/mainlogosvg';
export default function Home() {
const router = useRouter();
const containerRef = useRef<HTMLDivElement | null>(null);
const [currentIndex, setCurrentIndex] = useState(0);
const [userName, setUserName] = useState<string>('');
@@ -149,8 +151,18 @@ export default function Home() {
const data = await response.json();
if (isMounted && data.name) {
setUserName(data.name);
if (isMounted) {
// 사용자 권한 확인
const userRole = data.role || data.userRole;
if (userRole === 'ADMIN' || userRole === 'admin') {
// admin 권한이면 /admin/id로 리다이렉트
router.push('/admin/id');
return;
}
if (data.name) {
setUserName(data.name);
}
}
} catch (error) {
console.error('사용자 정보 조회 오류:', error);