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

M3-181 로그아웃 및 토큰 리프레시 구현 #26

Merged
merged 13 commits into from
Jul 12, 2024

Conversation

koomin1227
Copy link
Member

작업 내용*

  • 설정 페이지 구현
  • 로그아웃 기능 구현
  • 토큰 재발급 구현

고민한 내용*

로그아웃

  • 로그아웃 버튼을 눌렀을 때 바로 로그아웃이 되는 것이 아니라 확인하는 모달창을 한번 띄우고 확인을 한 경우만 로그아웃이 되도록 구현했다.
    try {
      await postLogout();
    } catch (e) {
      debugPrint('Error during logout: $e');
    } finally {
      await secureStorage.deleteAccessToken();
      await secureStorage.deleteRefreshToken();
      UserManager().init();
    }

위 코드 처럼 서버에 로그아웃 요청을 가장 먼저 보낸다. 하지만 서버가 실패하더라도 클라이언트에서는 로그아웃이 진행되도록 구현했다.

토큰 재발급

dio 의 interceptor 를 사용했다.

  • OnError 에서 401 상태가 감지되면 토큰 재발급 요청을 보낸다.
  • 재발급 요청에서도 실패하면 로그아웃 시킨다.

리뷰 요구사항

  • 리뷰할 때 중점적으로 봐줬으면 하는 내용들

스크린샷

Screenshot_20240711_145155 Screenshot_20240711_145142

@koomin1227 koomin1227 self-assigned this Jul 11, 2024
if (dioException.response?.statusCode == HttpStatus.unauthorized) {
AuthService().logout();
Get.offAllNamed('/login');
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

해당 부분 하나의 콜백이 너무 길어지는 느낌이 드는데, 한번 더 크게 묶어서 handleAuthorization() 같은 이름의 메소드로 묶는 건 어떨까요?

Copy link
Contributor

@tkdals802 tkdals802 left a comment

Choose a reason for hiding this comment

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

좋은 코드인것 같습니다

@koomin1227 koomin1227 merged commit f48c54f into develop Jul 12, 2024
1 check passed
@koomin1227 koomin1227 deleted the feature/M3-181-logoutAndRefresh branch July 12, 2024 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants