-
Notifications
You must be signed in to change notification settings - Fork 0
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] 온보딩 / 로그아웃 서버통신 구현 #112
Conversation
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.
굿굿!! 리뷰 확인해주세용
saveAccessToken("", "") | ||
Timber.e("액세스 토큰 만료, 토큰 재발급 합니다.") | ||
response.close() | ||
return handleTokenExpired(chain, originalRequest, headerRequest) |
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.
함수화 굿!!
} | ||
} | ||
|
||
private fun navigateToOnBoardingScreen() { |
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.
이름을 navigateToLoginScreen() 으로 바꾸는 게 좋을 거 같아요!
when (state) { | ||
is UiState.Failure -> { | ||
if (state is HttpException) { | ||
if (state.code() == 401) { |
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.
401이 어떤 코드인지 알 수 있게 CODE_[what]
으로 상수화 시켜주는 게 좋을 거 같아요!
Timber.e("${t.message}") | ||
_logoutState.value = UiState.Failure("${t.message}") | ||
} | ||
} |
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.
이 로직을 MainViewModel 말고, MyPageViewModel 에서 구현하는 건 어떨까요??
보통 activityViewModels 로 선언한 뷰모델은 여러 프래그먼트가 공유해서 사용하게 되는데, 로그아웃은 여러 프래그먼트에서 공통적으로 수행하는 동작이 아니므로, MainViewModel 보다는 MyPageViewModel 에서 로그아웃 로직을 처리하는 게 더 자연스럽다고 느껴져요!
MyPageViewModel 이 아니라, MainViewModel 에서 로그아웃 로직을 처리한 이유가 따로 있을까요??
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.
마이페이지 뿐만아니라, 서버통신시 리프레시토큰이 만료될 경우 로그아웃 처리를 해주어야해서 mainviewmodel에서 로직을 처리해 주었습니다. mypageviewmodel에서 처리를 한다면, 위니피드나 추천피드에서 서버통신 시 리프레시 토큰이 만료되었을경우엔 처리를 제대로 해주지 못할 것 같아서 mainviewmodel에서 구현했습니다 !
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.
아하! 리프레시 토큰이 만료되는 경우에도 로그아웃 해줘야 하는군요!! 답변 감사합니당 👍
|
||
is UiState.Success -> { | ||
navigateToOnBoardingScreen() | ||
Timber.e("로그인 액티비티로 전환") |
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.
navigateToLoginScreen 으로 함수 이름을 바꾼다면 굳이 로그를 찍지 않아도 될 거 같네요!
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.
어푸어푸~!
📝 Work Description
로그아웃 서버통신 구현
리프레시 토큰 만료시 자동 로그아웃
📸 Screenshot
📣 To Reviewers
내일 저녁까지 리뷰 부탁드립니다 !
토큰 재발급 서버와의 확인 결과 토큰 만료시 정상적으로 재발급됨이 확인되었습니다 !