Skip to content

Commit

Permalink
[MOD/#73] 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 12, 2024
1 parent 48e7291 commit 1c62950
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions data/src/main/java/com/going/data/interceptor/AuthInterceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ class AuthInterceptor @Inject constructor(
Timber.d("GET ACCESS TOKEN : ${dataStore.accessToken}")


// val authRequest = if (dataStore.accessToken.isNotBlank()) {
// originalRequest.newAuthBuilder().build()
// } else {
// originalRequest
// }
val authRequest = if (dataStore.accessToken.isNotBlank()) {
originalRequest.newAuthBuilder().build()
} else {
originalRequest
}

val authRequest = originalRequest.newAuthBuilder().build()
val response = chain.proceed(authRequest)

when (response.code) {
Expand Down Expand Up @@ -85,12 +84,10 @@ class AuthInterceptor @Inject constructor(
}
return response
}
//
// private fun Request.newAuthBuilder() =
// this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}")

private fun Request.newAuthBuilder() =
this.newBuilder().addHeader(AUTHORIZATION, "$BEARER eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2IiwiaWF0IjoxNzA0ODk1NDE4LCJleHAiOjE3MDU1MDAyMTh9.FWPJhGl9amOs1Aog1snD2O1ayVm6lRYBJgHOndyWdMQ")
private fun Request.newAuthBuilder() =
this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}")

companion object {
private const val CODE_TOKEN_EXPIRED = 401
private const val BEARER = "Bearer"
Expand Down

0 comments on commit 1c62950

Please sign in to comment.