Skip to content

fix(admin): redirect to /admin/login after logout#322

Merged
thxforall merged 1 commit into
devfrom
fix/admin-logout-redirect
Apr 23, 2026
Merged

fix(admin): redirect to /admin/login after logout#322
thxforall merged 1 commit into
devfrom
fix/admin-logout-redirect

Conversation

@thxforall
Copy link
Copy Markdown
Contributor

Summary

Admin 사이드바 로그아웃 버튼 클릭 시 DELETE /api/auth/session 은 200 반환하고 클라이언트 store state는 클리어되지만, 화면은 admin chrome 그대로 유지되고 로그인 페이지로 넘어가지 않는 UX 버그.

Root cause

  • AdminSidebar.handleLogoutuseAuthStore.logout() 만 호출
  • AdminLayoutReact Server Component → 클라이언트 auth state 변경에 재실행되지 않음 → admin chrome 잔존
  • 최초 도달한 admin 페이지는 user=null 이지만 이미 서버 렌더된 상태라 그대로 표시

Fix

AdminSidebar.handleLogout 에서 logout() 대기 후 router.replace("/admin/login") 호출. Replace 로 back-navigation 방지. Client 전환 시 layout 이 다시 돌아 login 페이지 fallback 이 적용됨.

async function handleLogout() {
  await logout();
  router.replace("/admin/login");
}

Test plan

  • bunx eslint lib/components/admin/AdminSidebar.tsx — pre-existing warning 외 이슈 없음
  • bunx tsc --noEmit — 신규 에러 0
  • 브라우저 수동 확인: admin 페이지에서 Logout 클릭 → 즉시 /admin/login 전환

스코프 외 (후속 후보)

  • SmartNav / profile-header-card / desktop-header 의 logout 도 동일 패턴 점검 필요 (public 페이지는 서버 레이아웃 재실행 패턴이 달라 증상이 다를 수 있음). 본 PR 은 admin 영역만.

AdminSidebar's handleLogout only cleared client auth state via the store.
AdminLayout is a React Server Component so it does not re-render on
client state changes — the admin chrome stayed on screen with stale data
until a hard navigation. The DELETE /api/auth/session call was returning
200 but the user saw no visual change.

Fix: after `logout()` resolves, call `router.replace("/admin/login")` so
the route transitions client-side and the server layout re-runs with
no user, falling back to the login page.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
decoded-app Building Building Preview, Comment Apr 23, 2026 11:24am

@thxforall thxforall merged commit 5105446 into dev Apr 23, 2026
3 of 4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in decoded-monorepo Apr 23, 2026
thxforall added a commit that referenced this pull request Apr 30, 2026
- router.replace()는 client soft-nav이라 AdminLayout(Server Component)이
  재실행되지 않아 로그아웃 후에도 사이드바가 그대로 남음.
- AuthProvider의 SIGNED_OUT 핸들러는 /api/auth/session DELETE를 비동기로
  호출하지만 handleLogout에서 await할 수 없어, 세션 쿠키가 살아있는 상태로
  /admin/login에 진입 → proxy.ts가 다시 /admin으로 바운스.
- 쿠키 DELETE를 inline에서 await한 뒤 window.location.assign()으로
  하드 네비게이션해 layout RSC가 admin chrome 없이 재렌더되도록 수정.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant