[Feat] Token Header 삽입#130
Conversation
📝 WalkthroughWalkthroughOkHttp 클라이언트에 Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant OkHttp as OkHttp
participant TokenInterceptor as TokenInterceptor
participant Preferences as PreferencesManager
participant Server as Server
Client->>OkHttp: 요청 실행
OkHttp->>TokenInterceptor: intercept(chain)
TokenInterceptor->>Preferences: ACCESS_TOKEN 조회 (runBlocking)
Preferences-->>TokenInterceptor: 토큰 반환
TokenInterceptor->>TokenInterceptor: 토큰이 있으면 Authorization 헤더 추가
TokenInterceptor->>OkHttp: chain.proceed(수정된 요청)
OkHttp->>Server: HTTP 요청 전송
Server-->>OkHttp: HTTP 응답 반환
OkHttp-->>Client: 응답 전달
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@app/src/main/java/com/flint/core/common/di/interceptor/TokenInterceptor.kt`:
- Around line 34-36: TokenInterceptor currently adds refreshToken to every
request via requestBuilder.header("refreshtoken", refreshToken); change this to
only add the header for the token refresh endpoint by checking the request URL
(use originalRequest.url.encodedPath or similar) and only call
requestBuilder.header when refreshToken is not empty AND the path matches the
refresh endpoint (e.g., contains "/auth/refresh"); update TokenInterceptor to
implement this conditional logic so other API calls do not carry the refresh
token.
🧹 Nitpick comments (1)
app/src/main/java/com/flint/core/common/di/interceptor/TokenInterceptor.kt (1)
18-26: 두 개의runBlocking호출을 하나로 통합하세요.현재
runBlocking을 두 번 호출하여 불필요한 오버헤드가 발생합니다. 단일runBlocking블록 내에서 두 토큰을 모두 가져오는 것이 더 효율적입니다.♻️ 제안하는 리팩토링
- val accessToken = - runBlocking { - preferencesManager.getString(ACCESS_TOKEN).first() - } - - val refreshToken = - runBlocking { - preferencesManager.getString(REFRESH_TOKEN).first() - } + val (accessToken, refreshToken) = runBlocking { + preferencesManager.getString(ACCESS_TOKEN).first() to + preferencesManager.getString(REFRESH_TOKEN).first() + }
giovannijunseokim
left a comment
There was a problem hiding this comment.
runBlocking이 메인 스레드 차단하지 않는지만 확인 부탁드립니다~!
LGTM 👍
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@app/src/main/java/com/flint/core/common/manager/KakaoLoginManager.kt`:
- Line 1: Update the import in LoginScreen.kt to reference the moved
KakaoLoginManager class: locate the import statement currently referencing
com.flint.presentation.login.manager.KakaoLoginManager and change it to import
com.flint.core.common.manager.KakaoLoginManager so the LoginScreen.kt uses the
new package for the KakaoLoginManager class.
🧹 Nitpick comments (1)
app/src/main/java/com/flint/core/common/di/interceptor/TokenInterceptor.kt (1)
5-5: 사용되지 않는 import 제거
REFRESH_TOKEN이 import 되었지만 실제로 사용되지 않습니다. 불필요한 import는 제거하세요.♻️ 수정 제안
import com.flint.core.common.datastore.PreferencesManager import com.flint.core.common.util.DataStoreKey.ACCESS_TOKEN -import com.flint.core.common.util.DataStoreKey.REFRESH_TOKEN import kotlinx.coroutines.flow.first
📮 관련 이슈
📌 작업 내용
Summary by CodeRabbit
릴리스 노트
개선 사항
잡무
✏️ Tip: You can customize this high-level summary in your review settings.