cannalee90 / flash-card

Flashcard web application
4 stars 0 forks source link

signout #29

Closed cannalee90 closed 6 years ago

cannalee90 commented 6 years ago
  1. reduxStore를 완전히 비운다
  2. 저장해둔 token을 지운다
  3. 로그인 페이지로 리다이렉트 한다.

https://stackoverflow.com/questions/35622588/how-to-reset-the-state-of-a-redux-store

리덕스 스토어 리셋하는 방법

cannalee90 commented 6 years ago

스토어를 리셋시키는 방법만으론 리다이렉트를 안한다.

cannalee90 commented 6 years ago

private route도 작동을 안한다.

cannalee90 commented 6 years ago

firebase가 새롭게 받아온다..? 로그아웃 된게 아닌가?

cannalee90 commented 6 years ago

signInWithPopup()으로 해결함.

cannalee90 commented 6 years ago
  1. 로그인 안된상태로 privateRoute로 접근하면 일단 <App />렌더링
cannalee90 commented 6 years ago

userSignout 액션보다 먼저 url바뀌는 문제가 있었는데, firebase의 signout을 하면 일단 루트로 튕겨서 그런것 같..다

cannalee90 commented 6 years ago

조금씩 이상하게 작동했던 이유가 토큰이 user.accessToken에 저장되어 있을 경우 userFetchInfo()를 디스패치 하도록(토큰이 있는 상태에서 '/' 로 url에 바로 접속하는 경우를 가정) comonentWillMount() 함수에서 코딩했는데, componentWillMount()가 내 생각대로 돌아가지 않아서 가끔 문제가 발생했었다.

해당 함수를 componentDidMount()에서 실행하니 제대로 동작함.

cannalee90 commented 6 years ago

currentUser가 있고 현재 signIn한 상태가 아닐경우 강제로 파이어베이스에 로그아웃 리퀘스트를 날리도록 설정