-
Notifications
You must be signed in to change notification settings - Fork 0
로그인 API 연결 #30
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
Merged
Merged
로그인 API 연결 #30
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8007e83
feat: 카카오 로그인 후 원래 페이지 복귀 기능 구현
yoouyeon a0fb892
fix: 인증 체크 API 경로 수정 및 mock 옵션 제거
yoouyeon 903e2ea
refactor: auth loader를 features 레이어로 이동
yoouyeon d55c595
feat: 로그인 페이지 진입 시 인증 상태 확인 loader 추가
yoouyeon 22750dd
fix: axios 인터셉터에서 401 시 redirectTo 파라미터 포함
yoouyeon d991b76
refactor: Supabase 관련 코드 제거 및 baseURL 정리
yoouyeon 908d7cc
feat: 게스트 토큰을 cookie에 저장하는 방식으로 변경
yoouyeon 0332532
feat: 401 응답 시 토큰 재발급 후 원래 요청 재시도
yoouyeon c4a67f2
fix: 로그아웃 API 경로 수정 및 mock 옵션 제거
yoouyeon 0fe504c
fix: 서비스 탈퇴 API 경로 수정 및 mock 옵션 제거
yoouyeon 62301fe
fix: 사용자 정보 조회 API 경로 수정 및 User 타입 API 응답에 맞게 수정
yoouyeon d4eb76c
refactor: 게스트 토큰 발급에서 TanStack Query 제거
yoouyeon 33a7fca
fix: redirectTo 파라미터 Open Redirect 취약점 방어
yoouyeon 8309bd3
fix: checkAuth 에러 처리 개선 및 redirectTo에 search, hash 포함
yoouyeon f262287
fix: 초기 랜더 상황을 위한 null guard
yoouyeon 384fdc3
fix: 토큰 재발급 시 무한 루프 방지를 위해 refreshClient 분리
yoouyeon 7848c84
Merge branch 'develop' into feat/MD-25
yoouyeon 4daba49
fix: 게스트 로그인 후 auth 캐시 제거로 checkAuth 재검증
yoouyeon 792bf3b
fix: 개발 환경 cross-origin 쿠키 차단 문제 해결
yoouyeon 3868a42
fix: 토큰 재발급 실패 시 401만 로그인으로 redirect, 나머지는 상위로 전파
yoouyeon 68cdded
fix: VITE_SERVER_URL 미설정 시 Storybook 빌드 오류 수정
yoouyeon 61fa24a
fix: 게스트 로그인 실패 시 에러 토스트 표시
yoouyeon 767f196
fix: proxy cookieDomainRewrite 와일드카드 적용과 URL 파싱 안전성 보강
yoouyeon 6169b94
fix: 로그인 버튼 연타 방지 로직 추가
yoouyeon 551da15
refactor: 안전한 경로를 반환하는 로직을 getSafeRedirectPath 유틸로 모듈화
yoouyeon eb9f106
refactor: URL.canParse를 이용해서 URL 검증 단계를 직관적으로 표시함
yoouyeon a108e92
Merge remote-tracking branch 'origin/develop' into feat/MD-25
yoouyeon f0b0d4e
fix: redirect 경로 검증 고도화
yoouyeon 5f343ce
fix: loader 인증 체크를 getUserInfo 대신 getAuth로 교체
yoouyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,14 @@ | ||
| export interface User { | ||
| id: number; | ||
| email: string; | ||
| name: string; | ||
| profileImageUrl?: string; | ||
| profile?: string; | ||
| } | ||
|
|
||
| export interface AuthCheckResponse { | ||
| authenticated: boolean; | ||
| user?: { | ||
| id: number; | ||
| role: string; | ||
| }; | ||
| reason?: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,5 @@ | ||
| import axiosInstance from '@/shared/api/axios'; | ||
|
|
||
| export const logout = () => | ||
| axiosInstance.post('/user/logout', null, { useMock: true }); | ||
| export const logout = () => axiosInstance.post('/logout'); | ||
|
|
||
| export const unregister = () => | ||
| axiosInstance.delete('/users/me', { | ||
| useMock: true, | ||
| }); | ||
| export const unregister = () => axiosInstance.delete('/unlink'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { redirect } from 'react-router'; | ||
| import type { LoaderFunctionArgs } from 'react-router'; | ||
| import { queryClient } from '@/shared/api/queryClient'; | ||
| import { getAuth } from '@/entities/auth/api/auth'; | ||
| import getSafeRedirectPath from '@/shared/lib/getSafeRedirectPath'; | ||
|
|
||
| /** | ||
| * 로그인 페이지 진입 전에 실행되는 loader | ||
| * 이미 인증된 상태라면 redirectTo 또는 홈으로 redirect한다. | ||
| */ | ||
| const checkAlreadyAuthLoader = async ({ request }: LoaderFunctionArgs) => { | ||
| try { | ||
| const user = await queryClient.ensureQueryData({ | ||
| queryKey: ['auth', 'user'], | ||
| queryFn: getAuth, | ||
| staleTime: 5 * 60 * 1000, | ||
| gcTime: 10 * 60 * 1000, | ||
| }); | ||
|
|
||
| if (user?.authenticated) { | ||
| const redirectTo = new URL(request.url).searchParams.get('redirectTo'); | ||
| return redirect(getSafeRedirectPath(redirectTo)); | ||
| } | ||
| } catch { | ||
| // 인증 실패 시 로그인 페이지 렌더링 | ||
| } | ||
|
|
||
| return null; | ||
| }; | ||
|
|
||
| export default checkAlreadyAuthLoader; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { redirect } from 'react-router'; | ||
| import type { LoaderFunctionArgs } from 'react-router'; | ||
| import { ROUTE } from '@/shared/config/route'; | ||
| import { queryClient } from '@/shared/api/queryClient'; | ||
| import { getAuth } from '@/entities/auth/api/auth'; | ||
|
|
||
| /** | ||
| * 페이지에 접근하기 전에 실행되는 함수 | ||
| * */ | ||
| const checkAuth = async ({ request }: LoaderFunctionArgs) => { | ||
| const user = await queryClient.ensureQueryData({ | ||
| queryKey: ['auth', 'user'], | ||
| queryFn: getAuth, | ||
| staleTime: 5 * 60 * 1000, // 5 minutes | ||
| gcTime: 10 * 60 * 1000, // 10 minutes | ||
| }); | ||
|
|
||
| if (!user || !user.authenticated) { | ||
| const { pathname, search, hash } = new URL(request.url); | ||
| const redirectTo = `${pathname}${search}${hash}`; | ||
| return redirect( | ||
| `${ROUTE.login}?redirectTo=${encodeURIComponent(redirectTo)}` | ||
| ); | ||
| } | ||
|
|
||
| // 5xx, 네트워크 오류 등 인증과 무관한 에러는 상위로 throw → RouteErrorElement에서 처리 (error를 여기서 캐치하지 않습니다.) | ||
| return user; | ||
| }; | ||
|
|
||
| export default checkAuth; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.