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

[FE] issue81: 로그인, 로그아웃 구현 #93

Merged
merged 7 commits into from
Jul 20, 2022
Merged

Conversation

nan-noo
Copy link
Collaborator

@nan-noo nan-noo commented Jul 20, 2022

요약

헤더에 로그인 및 로그아웃 버튼 구현

세부사항

  • 로그인: 깃헙 로그인 -> /login 페이지로 리다이렉트 -> 서버로 인증 -> 토큰 조회 및 localStorage에 저장 + isLoggedIn 상태 true
  • 로그아웃: accessToken localStorage에서 제거 + isLoggedIn 상태 false

추후 변경 가능 사항

나중에 MyPage 구현시 로그아웃 버튼을 페이지 내부로 옮길 예정
Avatar 정보를 서버에서 가져와야 함

주의사항: 추후 배포할 때 깃헙 OAuth에 등록한 콜백 URL이 바뀔 수 있음

close #81

@nan-noo nan-noo added 🚀 feature New feature or request 😁 frontend New frontend feature labels Jul 20, 2022
@nan-noo nan-noo requested a review from airman5573 July 20, 2022 02:44
@nan-noo nan-noo self-assigned this Jul 20, 2022
@nan-noo nan-noo linked an issue Jul 20, 2022 that may be closed by this pull request
Copy link
Collaborator

@airman5573 airman5573 left a comment

Choose a reason for hiding this comment

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

코드 잘 봤습니다. 수고했스요~ 머지 할께요!

setIsLoggedIn: React.Dispatch<React.SetStateAction<boolean>>;
}

const hasAccessToken = !!window.localStorage.getItem('accessToken');
Copy link
Collaborator

Choose a reason for hiding this comment

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

accessToken 상수로 빼주세용

});

export const LoginProvider = ({ children }: LoginProviderProps) => {
const [isLoggedIn, setIsLoggedIn] = useState(hasAccessToken);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const [isLoggedIn, setIsLoggedIn] = useState(hasAccessToken);
const [isLoggedIn, setIsLoggedIn] = useState(() => !!window.localStorage.getItem('accessToken'));

이런건 어떨까요? 보기가 좋아서요 ~

@airman5573 airman5573 merged commit 856a216 into develop Jul 20, 2022
@airman5573 airman5573 deleted the feat/81-login branch July 20, 2022 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feature New feature or request 😁 frontend New frontend feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] 로그인 기능 구현
2 participants