260508_17_ENH: 클라이언트 강력 요청으로 로그인 아예 걷고 파라미터 기반으로 admin 기능 우회
This commit is contained in:
@@ -69,27 +69,31 @@ const Header = ({
|
||||
<h1 className="font-bold content-text-2xl text-header-color">{SITE_TITLE}</h1>
|
||||
</div>
|
||||
<div className="flex min-w-0 items-center justify-end gap-4">
|
||||
{isAuthenticated && (
|
||||
<span className="content-text-base text-header-color hidden max-w-40 truncate sm:inline font-bold">
|
||||
{userName}
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
className="gap-2 border border-transparent bg-green-600 text-white w-25 shadow-sm hover:bg-green-500 hover:text-white"
|
||||
onClick={isAuthenticated ? onLogout : onLogin}
|
||||
>
|
||||
{isAuthenticated ? (
|
||||
<>
|
||||
<LogOut className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"로그아웃"}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<LogIn className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"로그인"}</span>
|
||||
</>
|
||||
{
|
||||
/* 클라이언트 요청으로 로그인 제외
|
||||
{isAuthenticated && (
|
||||
<span className="content-text-base text-header-color hidden max-w-40 truncate sm:inline font-bold">
|
||||
{userName}
|
||||
</span>
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
className="gap-2 border border-transparent bg-green-600 text-white w-25 shadow-sm hover:bg-green-500 hover:text-white"
|
||||
onClick={isAuthenticated ? onLogout : onLogin}
|
||||
>
|
||||
{isAuthenticated ? (
|
||||
<>
|
||||
<LogOut className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"관리자 로그아웃"}</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<LogIn className="w-4 h-4" />
|
||||
<span className="hidden sm:inline">{"관리자 로그인"}</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
*/
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import {ReactNode, useEffect, useState} from "react";
|
||||
import {useRouter} from "next/navigation";
|
||||
import {useRouter, useSearchParams} from "next/navigation";
|
||||
import {DivKey} from "@/types/kfpa";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {LayoutCategoryProvider} from "./LayoutCategoryContext";
|
||||
@@ -12,6 +12,7 @@ import {TOP_MENUS, SIDE_MENUS} from "@/config/menu.data";
|
||||
import {useLogoutMutation} from "@/query/auth";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import LoginDialog from "@/components/dialog/loginDialog";
|
||||
import { appendAdminRouteParam, hasAdminRouteParam } from "@/lib/admin-route";
|
||||
|
||||
type MainLayoutProps = {
|
||||
children: ReactNode;
|
||||
@@ -26,13 +27,15 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
const { showDialog } = useDialog();
|
||||
const logoutMutation = useLogoutMutation();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const isMounted = useMounted();
|
||||
|
||||
const [menuOpen, setMenuOpen] = useState(true);
|
||||
const [selectedDiv, setSelectedDiv] = useState<DivKey>(getDivKey());
|
||||
const isRouteAdmin = hasAdminRouteParam(searchParams);
|
||||
|
||||
const movePage = (path: string) => {
|
||||
router.push(path);
|
||||
router.push(appendAdminRouteParam(path, searchParams));
|
||||
};
|
||||
|
||||
const openLoginDialog = () => {
|
||||
@@ -60,7 +63,7 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
<Header
|
||||
topMenus={TOP_MENUS}
|
||||
userName={auth.user?.userName || ""}
|
||||
isAuthenticated={auth.user != null}
|
||||
isAuthenticated={isRouteAdmin}
|
||||
onNavigate={movePage}
|
||||
onLogin={openLoginDialog}
|
||||
onLogout={handleLogout}
|
||||
|
||||
Reference in New Issue
Block a user