From 41bb0f9f67a85ac8e17d766492f79a2997d3c6e9 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Mon, 1 Dec 2025 16:13:43 +0900
Subject: (김준회) 권한관리: 페이지 조회 권한 확인 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/common/permission-checker.tsx | 36 ++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 components/common/permission-checker.tsx

(limited to 'components/common/permission-checker.tsx')

diff --git a/components/common/permission-checker.tsx b/components/common/permission-checker.tsx
new file mode 100644
index 00000000..209e0022
--- /dev/null
+++ b/components/common/permission-checker.tsx
@@ -0,0 +1,36 @@
+"use client";
+
+import { useEffect } from "react";
+import { toast } from "sonner";
+import { usePathname } from "next/navigation";
+
+interface PermissionCheckerProps {
+  authorized: boolean;
+  message?: string;
+}
+
+export function PermissionChecker({ authorized, message }: PermissionCheckerProps) {
+  const pathname = usePathname();
+
+  useEffect(() => {
+    // Only show toast if authorization failed
+    if (!authorized) {
+      toast.error("Permission Denied", {
+        description: message || "You do not have permission to view this page. (Dev Mode: Viewing anyway)",
+        duration: 5000,
+        action: {
+          label: "Close",
+          onClick: () => toast.dismiss(),
+        },
+      });
+    } else {
+      // Optional: Show success toast only if explicitly needed, 
+      // but usually we don't show toast for success to avoid noise.
+      // Uncomment for debugging:
+      toast.success("Authorized", { description: "Access granted.", duration: 1000 });
+    }
+  }, [authorized, message, pathname]);
+
+  return null;
+}
+
-- 
cgit v1.2.3

