feat(frontend): 인증 연동 (로그인/로그아웃/내정보/라우트 가드)
- 로그인 실연동: 성공 시 access/refresh 토큰 저장, me 캐시 무효화 - SidebarFooter: useMeQuery 로 공급사명 표시, useLogoutMutation 로 로그아웃 - RequireAuth 가드로 /list·/chat 보호, 토큰 없으면 로그인으로 - 인증 만료/폐기 시 로그인 페이지로 이동(setUnauthorizedHandler) - LoginPage: 이미 로그인 상태면 목록으로 리다이렉트 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7bdd10207a
commit
c0d224ef21
6 files changed
+60
-18
No files matched your search
@@ -1,18 +1,30 @@
|
||||
import { useNavigate } from 'react-router'
|
||||
import { useLogoutMutation, useMeQuery } from '@/apis'
|
||||
import { Button } from '@/components'
|
||||
|
||||
// 사이드바 하단: 공급사명 + 로그아웃
|
||||
export function SidebarFooter() {
|
||||
const navigate = useNavigate()
|
||||
const { data: user } = useMeQuery()
|
||||
const logout = useLogoutMutation()
|
||||
|
||||
const handleLogout = () => {
|
||||
logout.mutate(undefined, {
|
||||
onSuccess: () => navigate('/'),
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full h-[60px] py-3 px-8 gap-3 items-center">
|
||||
<div className="flex-1 flex items-center min-w-0 text-sm text-foreground">
|
||||
{/* TODO: 공급사명 (auth store 연동) */}
|
||||
<span className="truncate">-</span>
|
||||
<span className="truncate">{user?.supplierName ?? '-'}</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
className="w-[61px] px-2 rounded-[4px] text-xs flex-shrink-0"
|
||||
// TODO: 로그아웃 mutation 연동
|
||||
onClick={handleLogout}
|
||||
disabled={logout.isPending}
|
||||
>
|
||||
로그아웃
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user