-
Notifications
You must be signed in to change notification settings - Fork 3
fix: auth 리디렉션 정책 단순화 및 로그인 후 메인 이동 통일 #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ import type { NextRequest } from "next/server"; | |
| import { NextResponse } from "next/server"; | ||
|
|
||
| const loginNeedPages = ["/mentor", "/my", "/community"]; // 로그인 필요페이지 | ||
| const COMMUNITY_LOGIN_REASON = "community-members-only"; | ||
|
|
||
| export function middleware(request: NextRequest) { | ||
| const url = request.nextUrl.clone(); | ||
|
|
@@ -12,13 +11,6 @@ export function middleware(request: NextRequest) { | |
| // return NextResponse.next(); | ||
| // } | ||
|
|
||
| // 서버 사이드 인증 체크가 활성화된 경우에만 미들웨어 적용 | ||
| // (RefreshToken은 항상 HTTP-only 쿠키로 관리됨) | ||
| const isServerSideAuthEnabled = process.env.NEXT_PUBLIC_COOKIE_LOGIN_ENABLED === "true"; | ||
| if (!isServerSideAuthEnabled) { | ||
| return NextResponse.next(); | ||
| } | ||
|
|
||
| // HTTP-only 쿠키의 refreshToken 확인 | ||
| const refreshToken = request.cookies.get("refreshToken")?.value; | ||
|
Comment on lines
14
to
15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The middleware now always enforces Useful? React with 👍 / 👎. |
||
|
|
||
|
|
@@ -28,13 +20,8 @@ export function middleware(request: NextRequest) { | |
| }); | ||
|
|
||
| if (needLogin && !refreshToken) { | ||
| const isCommunityRoute = url.pathname === "/community" || url.pathname.startsWith("/community/"); | ||
| url.pathname = "/login"; | ||
| if (isCommunityRoute) { | ||
| url.searchParams.set("reason", COMMUNITY_LOGIN_REASON); | ||
| } else { | ||
| url.searchParams.delete("reason"); | ||
| } | ||
| url.searchParams.delete("reason"); | ||
| return NextResponse.redirect(url); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
data.isRegisteredisfalse, this success path still shows a login-success toast and redirects to/, which skips onboarding for first-time Apple users. The unregistered Apple response type only providessignUpToken(noaccessToken) inapps/web/src/apis/Auth/api.ts, so these users cannot become authenticated on/and lose the only token needed to continue via/sign-up?token=....Useful? React with 👍 / 👎.