Skip to content
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

✨ Feat: PrivateRoute 구현 #36

Merged
merged 1 commit into from
Sep 14, 2023
Merged

✨ Feat: PrivateRoute 구현 #36

merged 1 commit into from
Sep 14, 2023

Conversation

suyeon1218
Copy link
Collaborator

🪄 변경사항

PrivateRoute 구현

인증되지 않은 사용자가 로그인이 필요한 서비스에 접근하려고 하는 경우 JWT 토큰을 검사하여 Login 페이지로 이동하는 라우터 기능을 구현했습니다.

인증되지 않은 사용자의 경우 로그인 페이지로 이동합니다. 로그인이 성공하면 리다이렉트 페이지로 이동합니다.

/login?redirectUrl=/meditation

🖥 결과 화면

/login?ridrectUrl=/meditation
Untitled
/meditation
Untitled2

✏️ PR 포인트

궁금하거나 수정해야할 사항 자유롭게 남겨주세요!

@suyeon1218 suyeon1218 self-assigned this Sep 13, 2023
Copy link
Member

@imb96 imb96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM👍

const userInfo = useRecoilValue(userState);

if (userInfo === null) {
return <Navigate to={`/login?redirectUrl=${path}`} />
Copy link
Member

@imb96 imb96 Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오... 이렇게 하는거였군요
쿼리를 잘 몰라서 그러는데 redirectUrl이란 이름은 수연님이 지으신거죠?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 아닙니다! 저게 리다이렉트 할 수 있게 해주는 표준이름(?) 인 거 같아요!

@suyeon1218 suyeon1218 merged commit 8041c12 into main Sep 14, 2023
@suyeon1218 suyeon1218 deleted the feat/privateRoute branch September 14, 2023 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants