-
Notifications
You must be signed in to change notification settings - Fork 1
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
[#43] 로그인 성공 시 쿠키 저장 #45
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.
빠르게 구현, 고생많으셨습니다!
export const getCookies: GetCookies = name => { | ||
const cookieValue = document.cookie | ||
.split('; ') | ||
.find(row => row.startsWith(`${name}=`)) | ||
?.split('=')[1]; | ||
return cookieValue; | ||
}; |
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.
accessToken을 가져오기 위해서는 원하는 곳에서
getCookies('accessToken')';
이런 식으로 반환받으면 될까요?
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.
고생하셨습니다!
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.
회의 때 이야기 나누면 좋을 것 같습니다!
@@ -22,3 +22,5 @@ dist-ssr | |||
*.njsproj | |||
*.sln | |||
*.sw? | |||
|
|||
.env |
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.
파일 마지막은 항상 개행 부탁드립니다!
https://blog.coderifleman.com/2015/04/04/text-files-end-with-a-newline/
try { | ||
document.cookie = `userName=${userName};max-age=${expiresIn};path=/;secure`; | ||
document.cookie = `userEmail=${userEmail};max-age=${expiresIn};path=/;secure`; | ||
document.cookie = `accessToken=${accessToken};max-age=${expiresIn};path=/;secure`; | ||
document.cookie = `refreshToken=${refreshToken};max-age=${expiresIn};path=/;secure`; | ||
console.log('쿠키설정 성공'); | ||
} catch (error) { | ||
console.log(error); | ||
alert('쿠키설정에 실패했습니다.'); | ||
} | ||
}; |
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.
이 부분 merge 이후에 error boundary 호출할 수 있게 테스트 겸 제가 변경해도 될까요?
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.
확인했습니다 빠르게 구현하시느라 수고 많으셨습니다!
close #43
Description
로그인 성공 시 setCookies로 사용자 정보 (이름, 이메일, 토큰 등)을 쿠키에 저장하고
getCookies를 통해 필요한 곳에서 사용자 정보를 불러와 사용할 수 있습니다.
유의할 점 및 ETC (Optional)
axios 설치했기 때문에, pull받으신 후
npm ci
한 번 씩 부탁드립니다!.env 파일 생성하였습니다.
.gitignore
과 같은 위치에 파일 생성하여 아래 내용 복붙해주시면 됩니다!