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: 로그인 시 토큰 저장 및 middleware 설정 #40

Merged
merged 7 commits into from
Jun 3, 2024

Conversation

DHyeon98
Copy link
Contributor

@DHyeon98 DHyeon98 commented May 31, 2024

#️⃣연관된 이슈

ex) #이슈번호, #이슈번호
#24 #39

📝작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

start-family

  • 로그인 성공시 쿼리의 토큰값을 받아서 쿠키로 저장.
  • 텍스트 padding 수정

middleware

  • 로그인 상태로 로그인 페이지 접근시 리다이렉션
  • 비로그인 상태로 로그인 필요 페이지 접근시 리다이렉션
  • start-family 페이지 접근시 조건 확인하여 리다이렉션

스크린샷 (선택)

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

@DHyeon98 DHyeon98 added the Feature Feature label May 31, 2024
@DHyeon98 DHyeon98 self-assigned this May 31, 2024
middleware.ts Outdated
// /start-family 페이지로 접근하는데 token이 없을 경우 : 리다이렉션
// /start-family 페이지로 접근하는데 token이 없지만 쿠키가 있을 경우 : 페이지 접근
// 추후 배포됐을 때 수정.
if (path === '/start-family' && hasQuery) {
Copy link
Member

Choose a reason for hiding this comment

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

이부분은 고민을 더 해보는게 좋아보이네요. 이렇게 if문이 많이 생기면 가독성이 확 떨어집니다.
객체 맵핑을 사용해도 좋고, 아니면 더 줄일 수 있는 방법을 고민해봐야할듯 해요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵 수정하겠습니다!

Copy link
Contributor

@forestream forestream left a comment

Choose a reason for hiding this comment

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

미들웨어 쓰임새를 또 배웁니다. 고생하셨습니다~

middleware.ts Outdated
}

export const config = {
matcher: ['/login', '/start-family'],
Copy link
Contributor

Choose a reason for hiding this comment

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

matcher: [ ...PROTECTED_PAGES, ...PUBLIC_PAGES ]
여길 이렇게 바꿀 수 있을까 생각해봤습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오... 어떻게 넣을까 고민했었는데 스프레드가 있었군요
감사합니다 변경하겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

주석 덕분에 코드가 잘읽히네요!

@DHyeon98 DHyeon98 merged commit c658053 into develop Jun 3, 2024
2 checks passed
DHyeon98 added a commit to DHyeon98/Donggrina that referenced this pull request Jun 3, 2024
Feat: 로그인 시 토큰 저장 및 middleware 설정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants