권한설정 페이지 수정/student만
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user