Skip to content

Commit

Permalink
[Fix] kustaurant#98 Refresh Token 만료 시 로그아웃 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
MinseoSONG committed Nov 14, 2024
1 parent 115fb91 commit bbf8b60
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
4 changes: 1 addition & 3 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.kust.kustaurant.data.di

import android.content.Context
import android.content.Intent
import android.util.Log
import com.kust.kustaurant.data.getAccessToken
import com.kust.kustaurant.data.model.LoginResponse
import com.kust.kustaurant.data.remote.NewAccessTokenApi
import com.kust.kustaurant.data.saveAccessToken
import kotlinx.coroutines.runBlocking
import com.kust.kustaurant.presentation.ui.splash.StartActivity
import okhttp3.Authenticator
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
Expand All @@ -28,6 +26,7 @@ class TokenAuthenticator(private val context: Context) : Authenticator {
.header("Authorization", "Bearer $newToken")
.build()
} else {
handleLogout()
null
}
}
Expand All @@ -53,4 +52,16 @@ class TokenAuthenticator(private val context: Context) : Authenticator {
}
return null
}

private fun handleLogout(){
context.getSharedPreferences("app_preferences", Context.MODE_PRIVATE).edit().clear().apply()

val intent = Intent(context, StartActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TOP
}

context.startActivity(intent)
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.3.2"
agp = "8.7.0"
flexbox = "3.0.0"
kotlin = "1.9.23"
coreKtx = "1.13.1"
Expand Down

0 comments on commit bbf8b60

Please sign in to comment.