fix: allow owner role to access admin pages

This commit is contained in:
dyzulk
2025-12-30 20:14:39 +07:00
parent e64df76835
commit e7c02d5fa1
8 changed files with 63 additions and 14 deletions

View File

@@ -24,12 +24,13 @@ export default function RootCaManagementClient() {
const [isRenewing, setIsRenewing] = useState(false);
const [confirmRenewUuid, setConfirmRenewUuid] = useState<string | null>(null);
// Redirect if not admin (double security, backend also checks)
// Redirect if not admin or owner (double security, backend also checks)
const { isAdminOrOwner } = useAuth();
React.useEffect(() => {
if (user && user.role !== "admin") {
if (user && !isAdminOrOwner) {
router.push("/dashboard");
}
}, [user, router]);
}, [user, isAdminOrOwner, router]);
const handleRenew = async (uuid: string) => {
setIsRenewing(true);