@@ -58,12 +58,11 @@ class AuthInterceptor @Inject constructor(
5858 Timber .d(t.message)
5959 }
6060
61- terningDataStore.clearInfo()
61+ restartApp(MESSAGE_TOKEN_EXPIRED )
62+ }
6263
63- Handler (Looper .getMainLooper()).post {
64- Toast .makeText(context, TOKEN_EXPIRED_ERROR , Toast .LENGTH_LONG ).show()
65- ProcessPhoenix .triggerRebirth(context)
66- }
64+ CODE_MANY_REQUESTS -> {
65+ restartApp(MESSAGE_TOO_MANY_REQUESTS )
6766 }
6867 }
6968 return response
@@ -72,9 +71,20 @@ class AuthInterceptor @Inject constructor(
7271 private fun Request.Builder.newAuthBuilder () =
7372 this .addHeader(AUTHORIZATION , " $BEARER ${terningDataStore.accessToken} " )
7473
74+ private fun restartApp (message : String ) {
75+ terningDataStore.clearInfo()
76+
77+ Handler (Looper .getMainLooper()).post {
78+ Toast .makeText(context, message, Toast .LENGTH_LONG ).show()
79+ ProcessPhoenix .triggerRebirth(context)
80+ }
81+ }
82+
7583 companion object {
7684 private const val CODE_TOKEN_EXPIRED = 401
77- private const val TOKEN_EXPIRED_ERROR = " ν ν°μ΄ λ§λ£λμμ΄μ\n λ€μ λ‘κ·ΈμΈ ν΄μ£ΌμΈμ"
85+ private const val CODE_MANY_REQUESTS = 429
86+ private const val MESSAGE_TOKEN_EXPIRED = " ν ν°μ΄ λ§λ£λμμ΄μ\n λ€μ λ‘κ·ΈμΈ ν΄μ£ΌμΈμ"
87+ private const val MESSAGE_TOO_MANY_REQUESTS = " μμ² νμκ° λ무 λ§μμ\n λ‘κ·ΈμΈ ν λ€μ μλν΄ μ£ΌμΈμ"
7888 private const val BEARER = " Bearer"
7989 private const val AUTHORIZATION = " Authorization"
8090 }
0 commit comments