diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 718ce5e..b86273d 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,8 +1,6 @@
-
-
-
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
index 33e807b..e67a0f7 100644
--- a/.idea/deploymentTargetSelector.xml
+++ b/.idea/deploymentTargetSelector.xml
@@ -2,8 +2,16 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/kust/kustaurant/data/di/TokenAuthenticator.kt b/app/src/main/java/com/kust/kustaurant/data/di/TokenAuthenticator.kt
index a65ab55..4bc7932 100644
--- a/app/src/main/java/com/kust/kustaurant/data/di/TokenAuthenticator.kt
+++ b/app/src/main/java/com/kust/kustaurant/data/di/TokenAuthenticator.kt
@@ -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
@@ -28,6 +26,7 @@ class TokenAuthenticator(private val context: Context) : Authenticator {
.header("Authorization", "Bearer $newToken")
.build()
} else {
+ handleLogout()
null
}
}
@@ -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)
+ }
}
diff --git a/app/src/main/java/com/kust/kustaurant/data/remote/NewAccessTokenApi.kt b/app/src/main/java/com/kust/kustaurant/data/remote/NewAccessTokenApi.kt
deleted file mode 100644
index c6d3f6d..0000000
--- a/app/src/main/java/com/kust/kustaurant/data/remote/NewAccessTokenApi.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.kust.kustaurant.data.remote
-
-import com.kust.kustaurant.data.model.LoginResponse
-import okhttp3.ResponseBody
-import retrofit2.Call
-import retrofit2.http.Header
-import retrofit2.http.POST
-
-interface NewAccessTokenApi {
- @POST("/api/v1/new-access-token")
- fun refreshToken(@Header("Authorization") expiredToken : String): Call
-}
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 84b4c39..5fe2964 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -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"