Skip to content

Commit

Permalink
[CHORE/#124] 인터셉터 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
boiledEgg-s committed Jul 18, 2024
1 parent 4ac2f64 commit b01b039
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions app/src/main/java/com/terning/point/di/AuthInterceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,43 @@ class AuthInterceptor @Inject constructor(

val response = chain.proceed(authRequest)

// when (response.code) {
// CODE_TOKEN_EXPIRED -> {
// try {
// runBlocking {
// tokenReissueRepository.postReissueToken(
// terningDataStore.refreshToken
// )
// }.onSuccess { data ->
// terningDataStore.apply {
// refreshToken = data.refreshToken
// }
//
// response.close()
//
// val newRequest =
// authRequest.newBuilder().removeHeader(AUTHORIZATION).newAuthBuilder()
// .build()
//
// return chain.proceed(newRequest)
// }
// } catch (t: Throwable) {
// Timber.d(t.message)
// }
//
// terningDataStore.clearInfo()
//
// Handler(Looper.getMainLooper()).post {
// context.stringToast(TOKEN_EXPIRED_ERROR)
// Handler(Looper.getMainLooper()).post {
// ProcessPhoenix.triggerRebirth(
// context,
// Intent(context, MainActivity::class.java)
// )
// }
// }
// }
// }
when (response.code) {
CODE_TOKEN_EXPIRED -> {
try {
runBlocking {
tokenReissueRepository.postReissueToken(
terningDataStore.refreshToken
)
}.onSuccess { data ->
terningDataStore.apply {
refreshToken = data.refreshToken
}

response.close()

val newRequest =
authRequest.newBuilder().removeHeader(AUTHORIZATION).newAuthBuilder()
.build()

return chain.proceed(newRequest)
}
} catch (t: Throwable) {
Timber.d(t.message)
}

terningDataStore.clearInfo()

Handler(Looper.getMainLooper()).post {
context.stringToast(TOKEN_EXPIRED_ERROR)
Handler(Looper.getMainLooper()).post {
ProcessPhoenix.triggerRebirth(
context,
Intent(context, MainActivity::class.java)
)
}
}
}
}
return response
}

Expand Down

0 comments on commit b01b039

Please sign in to comment.