Refact/modify token operation#77
Open
sh1mj1 wants to merge 13 commits intoBA-BA-Project:Refact/modify_token_operationfrom
Open
Refact/modify token operation#77sh1mj1 wants to merge 13 commits intoBA-BA-Project:Refact/modify_token_operationfrom
sh1mj1 wants to merge 13 commits intoBA-BA-Project:Refact/modify_token_operationfrom
Conversation
added 13 commits
September 22, 2023 14:19
…불필요한 분기 제거, BabaRetrofit 과 RefreshTokenRetrofit 의 중복 코드 메서드로 분리
그에 따른 side effect 처리. 처음 로그인시 access, refresh token 이 없어, 계속해서 IntroActivity 가 호출되고 다시 사용자 정보 요청 api 를 호출하는 루프에 갇히는 문제를 GetMemberUseCase 의 getMe 메서드에 디폴트 패러미터를 넣어 해결
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Header 에 access token 을 hasAuthorization 분기 없이 넣어주기
Interceptor 에서 넣어주는 것으로 변경함.
Header 에 sign token 을 넣어주는 인터셉터 생성.
MemberApi 에서 회원 가입 동작을 하는 api 두개를
SignUpApi 라는 서비스 인터페이스를 추가해서 분리함.
ApiModule과NetworkModule에서 해당 인터셉터를 사용하도록 추가해줌.(
provideSignUpRetrofitprovideSignUpClientprovideSignUpAuthorizationInterceptor등 추가)Result 변경 사항
safeApiHelperImpl 에서 사용하는 onSuccess 함수는 코틀린 패키지의 Result 클래스의 함수임.
이에 대해서 저희가 만든 sealed class Result 와 혼동되어 ApiResult 로 이름 변경
SafeApiHelper 변경 사항
일반적인 Api 호출 이후에 401 에러가 발생하면 ApiResult 의 throwable 에
InvalidAccessToken을 가지도록 만듦.그리고 getSafe 함수의 마지막에 apiResult 가 Failure 이며
InvalidAccessToken이면 같은 api 를 재호출하도록 만듦.기존에는 아래처럼 재호출되지 않는 문제가 발생했었음.
https://tv.kakao.com/v/441288590
getSafe 메서드의 길이가 너무 길어서 가독성 문제가 우려되어 메서드를 분리함.
AuthClient 와 AuthorizationInterceptor 의 의존성 제거
AuthApi 가 호출하는 모든 api 는 헤더에 추가적인 내용이 필요 없음.

그래서 헤더에 토큰을 넣어주는 AuthorizationInterceptor 와 의존성을 가질 필요가 없어서 제거.
TokenAuthenticator 의 불필요한 분기 제거
객체 의존성 그림을 잘 보면 Refresh Token 으로 토큰을 갱신하는 역할을 하는 TokenAuthenticator 에 의존하는 객체는 오직 BabaClient 입니다.
즉, 의존성 구조 상 토큰을 갱신해야 해서 호출하는 AuthApi 에 의해서 다시
TokenAuthenticator가 호출될 수가 없음.isPathRefresh 라는 변수를 사용해서 무한 루프를 방지하고자 하는 부분도 필요없는 분기 코드임. 이를 제거
BabaRetrofit 과 RefreshTokenRetrofit 의 중복 코드 메서드 분리