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

[#43] 로그인 성공 시 쿠키 저장 #45

Merged
merged 8 commits into from
Jan 19, 2024
Merged

[#43] 로그인 성공 시 쿠키 저장 #45

merged 8 commits into from
Jan 19, 2024

Conversation

dabin-Hailey
Copy link
Collaborator

@dabin-Hailey dabin-Hailey commented Jan 17, 2024

close #43

Description

로그인 성공 시 setCookies로 사용자 정보 (이름, 이메일, 토큰 등)을 쿠키에 저장하고
getCookies를 통해 필요한 곳에서 사용자 정보를 불러와 사용할 수 있습니다.

  • axios 설치
  • axios instance 생성
  • setCookie, getCookie 함수 생성
  • 로그인 결과 쿠키에 저장

유의할 점 및 ETC (Optional)

  1. axios 설치했기 때문에, pull받으신 후 npm ci 한 번 씩 부탁드립니다!

  2. .env 파일 생성하였습니다. .gitignore과 같은 위치에 파일 생성하여 아래 내용 복붙해주시면 됩니다!

VITE_SERVER_URL = "https://coolpeace.store"
VITE_CONTENT_TYPE = "application/json"

@dabin-Hailey dabin-Hailey self-assigned this Jan 17, 2024
Copy link

vercel bot commented Jan 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cool-peace ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 18, 2024 6:51am
cool-peace-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 18, 2024 6:51am

Copy link
Collaborator

@turkey-kim turkey-kim left a comment

Choose a reason for hiding this comment

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

빠르게 구현, 고생많으셨습니다!

Comment on lines +22 to +28
export const getCookies: GetCookies = name => {
const cookieValue = document.cookie
.split('; ')
.find(row => row.startsWith(`${name}=`))
?.split('=')[1];
return cookieValue;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

accessToken을 가져오기 위해서는 원하는 곳에서

getCookies('accessToken')';

이런 식으로 반환받으면 될까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 맞습니다!

Copy link
Collaborator

@JitHoon JitHoon left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Copy link
Collaborator

@jinjoo-jung jinjoo-jung left a comment

Choose a reason for hiding this comment

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

빠르게 해주셨네요..!!!! 감사합니다 👍🏻

Copy link
Collaborator

@JitHoon JitHoon left a 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
Copy link
Collaborator

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/

Comment on lines +10 to +20
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('쿠키설정에 실패했습니다.');
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 부분 merge 이후에 error boundary 호출할 수 있게 테스트 겸 제가 변경해도 될까요?

Copy link
Member

@jiohjung98 jiohjung98 left a comment

Choose a reason for hiding this comment

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

확인했습니다 빠르게 구현하시느라 수고 많으셨습니다!

@dabin-Hailey dabin-Hailey merged commit fdd499b into dev Jan 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 기능 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 로그인 성공 시 쿠키 저장
5 participants