refactor(WEB): Server Action 공통화 및 보안 강화
- executeServerAction 공통 유틸 도입으로 actions.ts 대폭 간소화 (50+개 파일) - sanitize 유틸 추가 (XSS 방지) - middleware CSP 헤더 추가 및 Open Redirect 방지 - 프록시 라우트 로깅 개발환경 한정으로 변경 - 프로덕션 불필요 console.log 제거 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { safeJsonParse } from '@/lib/utils';
|
||||
|
||||
/**
|
||||
* 사용자 역할을 관리하는 최적화된 훅
|
||||
@@ -8,16 +9,14 @@ export function useUserRole() {
|
||||
const [userRole, setUserRole] = useState<string>(() => {
|
||||
// SSR-safe: 서버에서는 기본값 반환
|
||||
if (typeof window === 'undefined') return "CEO";
|
||||
const userDataStr = localStorage.getItem("user");
|
||||
const userData = userDataStr ? JSON.parse(userDataStr) : null;
|
||||
return userData?.role || "CEO";
|
||||
const userData = safeJsonParse<Record<string, unknown> | null>(localStorage.getItem("user"), null);
|
||||
return (userData?.role as string) || "CEO";
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const handleStorageChange = () => {
|
||||
const userDataStr = localStorage.getItem("user");
|
||||
const userData = userDataStr ? JSON.parse(userDataStr) : null;
|
||||
const newRole = userData?.role || "CEO";
|
||||
const userData = safeJsonParse<Record<string, unknown> | null>(localStorage.getItem("user"), null);
|
||||
const newRole = (userData?.role as string) || "CEO";
|
||||
setUserRole(newRole);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user