-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 티켓 UI 수정 및 티켓 취소 시 다중 선택 오류, 토큰 만료에 따른 로그아웃 오류 해결 #206
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
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1926b54
refact: 이벤트 내 티켓 구매 UI 수정
xaexunxang e237e7f
fix: errorCode 수정
xaexunxang c08dffc
fix: 타입 오타로 인한 티켓 취소 시 다중 삭제되는 오류 해결
xaexunxang 579feee
fix: errorCode에 따른 accessToken과 refreshToken 모두 만료되었을 때의 로그아웃 오류 해결
xaexunxang ad22eaf
fix: LogoutPage에 토큰 만료로 인한 로그아웃 예외처리 적용
xaexunxang abb86dd
fix: 토큰 타입 선언 및 불필요한 console.log 삭제
xaexunxang 9af50e7
fix: 토큰 만료 시 서버 응답 기반으로 자동 로그아웃 구현
xaexunxang 9ee5304
fix: 에러코드 타입 선언
xaexunxang 91dc9ff
fix: 에러코드 타입 재선언...
xaexunxang 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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { axiosClient } from './http-client'; | ||
| import useAuthStore from '../../../app/provider/authStore'; | ||
|
|
||
| // 타입 가드 함수 | ||
| function isTokenError(error: unknown): error is { code: string; status?: number } { | ||
| return error !== null && typeof error === 'object' && 'code' in error && typeof (error as any).code === 'string'; | ||
| } | ||
|
|
||
| // 토큰 유효성 검증 함수 (httpOnly 쿠키 사용) | ||
| export const validateToken = async (): Promise<boolean> => { | ||
| try { | ||
| // 토큰 유효성 검증을 위한 API 호출 (사용자 정보 조회) | ||
| await axiosClient.get('/users'); | ||
| return true; | ||
| } catch (error: unknown) { | ||
| // 토큰이 만료되었거나 유효하지 않은 경우 | ||
| if (isTokenError(error) && (error.code === 'TOKEN4001' || error.code === 'TOKEN4004' || error.status === 401)) { | ||
| return false; | ||
| } | ||
| // 다른 에러의 경우 토큰이 유효하다고 간주 | ||
| return true; | ||
| } | ||
| }; | ||
|
|
||
| // 앱 시작 시 토큰 검증 및 자동 로그아웃 | ||
| export const initializeAuth = async () => { | ||
| const authStore = useAuthStore.getState(); | ||
|
|
||
| // 로그인 상태가 아닌 경우 검증하지 않음 | ||
| if (!authStore.isLoggedIn) { | ||
| return; | ||
| } | ||
|
|
||
| const isValid = await validateToken(); | ||
|
|
||
| if (!isValid) { | ||
| // 토큰이 유효하지 않으면 로그아웃 처리 | ||
| // Zustand persist가 자동으로 localStorage를 정리하므로 수동 정리 불필요 | ||
| authStore.logout(); | ||
| authStore.openModal(); | ||
| } | ||
| }; | ||
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
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.