-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: logout timer 버그 수정 #202
Conversation
if (!userData) { | ||
redirect('/gatherings'); | ||
} |
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.
미들웨어에서 검사하던 로직 레아아웃 파일로 이동
const expirationTime = getTokenExpirationTime(token); // 만료시간 | ||
const currentTime = Date.now(); // 현재시간 | ||
const remainingTime = Math.max(0, expirationTime - currentTime); // 남은 시간 계산 | ||
setTimeLeft(Math.floor(remainingTime / 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.
원래는 토큰을 발급받은 뒤에 만료시간인 3600초에서 1초씩 빼는 로직으로 구현되었으나
현재는 서버에서 받아온 토큰에서 만료시간을 가져온 뒤에 현재시간에서 빼는 로직으로 리팩토링하였습니다.
이를 통해 로컬스토리지를 사용할 필요가 없어졌고 창이 닫히거나 비활성화 되었을 때 로컬스토리지에 로그아웃까지 남은 시간이 남아있는 문제를 해결했습니다.
@@ -32,7 +30,7 @@ const ProfileEditModal = ({ | |||
setProfileInput(e.target.value); | |||
}; | |||
|
|||
const isValid = profileInput !== user?.companyName && profileInput !== ''; | |||
const isValid = profileInput !== ''; |
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.
복잡한데 뚝딱 해결하셨네요 고생하셨습니다! 👍
@@ -14,7 +14,7 @@ export async function GET(req: Request) { | |||
const token = await getCookie('token'); | |||
|
|||
const response = await fetch( | |||
`${process.env.NEXT_PUBLIC_API_BASE_URL}/gatherings/joined?offset=${offset}&limit=${limit}`, | |||
`${process.env.NEXT_PUBLIC_API_BASE_URL}/gatherings/joined?offset=${offset}&limit=${limit}&sortOrder=desc`, |
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.
고생하셨습니다! LGTM 👏
✏️ 작업 내용
📷 스크린샷
프로필 수정
Oct-16-2024.17-24-56.mov
close #197