Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ class AuthInterceptor @Inject constructor(
Timber.d(t.message)
}

terningDataStore.clearInfo()
restartApp(MESSAGE_TOKEN_EXPIRED)
}

Handler(Looper.getMainLooper()).post {
Toast.makeText(context, TOKEN_EXPIRED_ERROR, Toast.LENGTH_LONG).show()
ProcessPhoenix.triggerRebirth(context)
}
CODE_MANY_REQUESTS -> {
restartApp(MESSAGE_TOO_MANY_REQUESTS)
}
}
return response
Expand All @@ -72,9 +71,20 @@ class AuthInterceptor @Inject constructor(
private fun Request.Builder.newAuthBuilder() =
this.addHeader(AUTHORIZATION, "$BEARER ${terningDataStore.accessToken}")

private fun restartApp(message: String) {
terningDataStore.clearInfo()

Handler(Looper.getMainLooper()).post {
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
ProcessPhoenix.triggerRebirth(context)
}
}

companion object {
private const val CODE_TOKEN_EXPIRED = 401
private const val TOKEN_EXPIRED_ERROR = "토큰이 만료되었어요\n다시 로그인 해주세요"
private const val CODE_MANY_REQUESTS = 429
private const val MESSAGE_TOKEN_EXPIRED = "토큰이 만료되었어요\n다시 로그인 해주세요"
private const val MESSAGE_TOO_MANY_REQUESTS = "요청 횟수가 너무 많아요\n로그인 후 다시 시도해 주세요"
Comment on lines 84 to +87
Copy link
Member

Choose a reason for hiding this comment

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

나중에 enum으로 관리하도록 수정하면 좋을 것 같아요!

private const val BEARER = "Bearer"
private const val AUTHORIZATION = "Authorization"
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
compileSdk = "35"
minSdk = "28"
targetSdk = "35"
versionName = "1.3.5"
versionCode = "103050"
versionName = "1.3.6"
versionCode = "103060"
jvmTarget = "1.8"

## Android gradle plugin
Expand Down