Skip to content

fix(admin): block /admin/login redirect loop for non-admin users#447

Merged
thxforall merged 1 commit into
devfrom
fix/admin-login-non-admin-redirect-loop
May 6, 2026
Merged

fix(admin): block /admin/login redirect loop for non-admin users#447
thxforall merged 1 commit into
devfrom
fix/admin-login-non-admin-redirect-loop

Conversation

@thxforall
Copy link
Copy Markdown
Contributor

Summary

  • PRD admin 로그인 시 Google OAuth 후 /admin ↔ /admin/login 무한 redirect 루프 차단
  • 5037b58b cherry-pick (feature/374-seaorm-integration-epic-plan에서 작성된 fix를 정공법으로 dev → main 흐름에 흘려보냄)

Changes

  • app/api/auth/session/route.ts: POST 응답에 isAdmin 필드 추가 (서버에서 checkIsAdmin 호출).
  • app/admin/login/page.tsx:
    • INITIAL_SESSION 분기 제거 — 비-admin이 /admin/login에 진입하면 INITIAL_SESSION → /admin → proxy → /admin/login → INITIAL_SESSION 루프가 생기는 구조였음.
    • SIGNED_IN 시 응답의 isAdmin 분기 — 비-admin은 즉시 sign out + 에러 표시.

Test plan

  • bun run lint (web) 통과
  • bun run typecheck (web) 통과
  • dev preview에서 admin 로그인 → /admin 정상 진입
  • dev preview에서 비-admin 로그인 시도 → "관리자 권한이 없는 계정입니다" 표시
  • PRD users 테이블 본인 is_admin = true 검증 (사용자)

Context

dev에는 이미 redirect-loop 안정화 fix들이 부분적으로 반영되어 있음 (b95bc077, d74b8098, 3d56da77, proxy.ts admin bounce). 본 PR은 마지막 누락분(5037b58b)을 채워 main까지 흘려보내기 위함.

🤖 Generated with Claude Code

INITIAL_SESSION 이벤트로 자동 /admin 이동 시 비-admin 세션 보유자가
proxy.ts → /admin/login 리다이렉트와 무한 루프에 빠지는 문제 수정.

- /api/auth/session POST 응답에 isAdmin 추가 (서버에서 checkIsAdmin 호출)
- /admin/login 페이지: SIGNED_IN 시 isAdmin 분기 — 비-admin 은 signOut +
  세션 쿠키 삭제 후 에러 메시지 표시. INITIAL_SESSION 분기는 제거 (이미
  proxy.ts 가 admin 인증된 사용자를 /admin 으로 바운스해 처리)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

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

Project Deployment Actions Updated (UTC)
decoded-app Ready Ready Preview, Comment May 5, 2026 11:50am

@thxforall thxforall marked this pull request as ready for review May 5, 2026 12:02
@thxforall thxforall merged commit a99575f into dev May 6, 2026
6 of 7 checks passed
@thxforall thxforall deleted the fix/admin-login-non-admin-redirect-loop branch May 6, 2026 04:40
@github-project-automation github-project-automation Bot moved this from Todo to Done in decoded-monorepo May 6, 2026
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