diff --git a/core/network/src/main/java/com/terning/core/network/AuthInterceptor.kt b/core/network/src/main/java/com/terning/core/network/AuthInterceptor.kt index cf8bf1eff..41c0c40a6 100644 --- a/core/network/src/main/java/com/terning/core/network/AuthInterceptor.kt +++ b/core/network/src/main/java/com/terning/core/network/AuthInterceptor.kt @@ -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 @@ -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로그인 후 다시 시도해 주세요" private const val BEARER = "Bearer" private const val AUTHORIZATION = "Authorization" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5eca7ca90..a4343b9d2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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