-
Notifications
You must be signed in to change notification settings - Fork 6
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
페이지 기능: 로그인 이후 토큰 인증에 따라 로그인 만료, 로그인 연장 처리 #182
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
고생하셨습니다!
}), | ||
|
||
/* ----- refresh token api success ----- */ | ||
http.post(`${process.env.NEXT_PUBLIC_BASE_URL}/auth/validToken`, () => { |
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.
이거 두개로 나누지 않고 조건문으로 분기 처리할 수 있지 않나요?
@@ -24,6 +24,12 @@ export const login = async ({ | |||
return response; | |||
}; | |||
|
|||
export const refreshToken = async () => { | |||
const response = await postRequest<RefreshTokenType, null>('/auth/validToken'); |
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는 지용님이 만들어주실 예정인가요?
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.
아마 그러실 것 같아요. 개발 예정이라고 하셨습니다!
|
||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import useLoggedOut from '@/hooks/useLoggedOut'; |
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.
import useLoggedOut from '@/hooks/useLoggedOut'; | |
import useLoggedOut from '@hooks/useLoggedOut'; |
}; | ||
|
||
const onError = () => { | ||
handleLogout('/login'); |
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.
다시 로그인 해주세요 표시를 토스트로 보여줘도 될 것 같네요
하나 만들겠습니다!
src/hooks/useIntervalRefreshToken.ts
Outdated
@@ -0,0 +1,22 @@ | |||
import useRefreshToken from '@remote/queries/auth/useRefreshToken'; | |||
|
|||
const JWT_EXPIRY_TIME = 15 * 60 * 1000; |
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.
서버 토큰 만료 시간이 15분이라 14분으로 맞춰도 될 것 같아요!
|
||
useEffect(() => { | ||
if (userId !== null) { | ||
startRefreshTokenInterval(); |
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.
기존에 가지고 있던 토큰을 이용해서 새로운 토큰을 발급 받을 예정이신거죠?
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.
넵 지용님이랑 얘기해봤는데 헤더 Authentication에 담아 보내주면 body에 새로운 토큰을 넣어서 보내주신다고 하십니다!
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.
아하 알겠습니다!
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.
굳!
해당 사항 (중복 선택)
설명
Key Changes
How it Works
To Reviewers
아직 api가 완성되지 않아 mock data 작성해서 진행했습니다.