-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 인증 인가 관련 토큰 로직 생성 #128
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 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2ae24ca
fix: 변경된 api 설계에 따라 refreshToken 변경
yoorli dd08514
feat: 토큰 처리 로직 생성
yoorli 729c547
feat: 토큰 재발급 msw 추가
yoorli e3139ce
Merge remote-tracking branch 'origin/main' into yoolri-feat/token-logic
yoorli b04c503
fix: 리뷰 사항 참고 수정
yoorli c468074
Merge branch 'main' into yoolri-feat/token-logic
yoorli f7c573a
fix: 추가된 공통 응답 처리 함수에 맞춰 로그인, 회원가입 코드 수정
yoorli 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
|
Member
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. getAccessToken과 clearAccessToken은 클라이언트에서만 사용되어야 하니까 서버 환경일 때는 error를 던져주면 디버깅에 용이할 것 같네요! |
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,19 @@ | ||
| const ACCESS_TOKEN_KEY = 'accessToken'; | ||
|
|
||
| export const setAccessToken = (token: string, maxAgeSeconds?: number) => { | ||
| if (typeof document === 'undefined') return; | ||
|
|
||
| const parts = [`${ACCESS_TOKEN_KEY}=${encodeURIComponent(token)}`, 'path=/']; | ||
|
|
||
| if (typeof maxAgeSeconds === 'number' && maxAgeSeconds > 0) { | ||
| parts.push(`Max-Age=${maxAgeSeconds}`); | ||
| } | ||
|
|
||
| document.cookie = parts.join('; '); | ||
| }; | ||
|
|
||
| export const clearAccessToken = () => { | ||
| if (typeof document === 'undefined') return; | ||
|
|
||
| document.cookie = `${ACCESS_TOKEN_KEY}=; Max-Age=0; path=/`; | ||
| }; |
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
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.
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.
로그인/회원가입은 직접 api 호출을 하고 있는 것 같은데, 맞다면 React Query를 사용하지 않는 거니까 해당 로직은 필요없어보입니다 :)
React Query를 사용하더라도 invalidateQueries의 용도는 useQuery 로 get한 데이터가 stale 됐다고 강제 변경한 뒤 데이터를 다시 refetch 해오는 용도로 쓰기 때문에 login에서는 필요 없을 것 같아요!