Skip to content
Snippets Groups Projects
Commit ade1176d authored by Kenneth Ezekiel's avatar Kenneth Ezekiel
Browse files

Merge branch 'login' of...

Merge branch 'login' of https://gitlab.informatika.org/IF3210-2024-Android-AVK/if3210-2024-android-avk into develop
parents 40c13031 caf70e35
No related merge requests found
package com.example.tubespbd.auth
import android.content.Intent
import android.util.Log
import com.example.tubespbd.LoginActivity
import com.example.tubespbd.interfaces.AuthService
import com.example.tubespbd.responses.LoginRequest
import com.example.tubespbd.responses.LoginResponse
......@@ -42,4 +44,11 @@ class LoginService {
}
}
}
fun logout() {
// Update the expiration, assumed the server time and client time is the same
TokenManager.getToken()
}
}
\ No newline at end of file
......@@ -109,11 +109,11 @@ class TokenExpirationService: Service() {
} else {
// Not keep logged in, initiate logout
Log.d("Redirect", "Token expired, logging out")
logout()
loginService.logout()
// Navigate to login page again
navigateToLogin()
}
} else {
// Handle unsuccessful response
Log.e("TokenExpirationService", "Token check failed: ${response.code()}")
......@@ -129,13 +129,6 @@ class TokenExpirationService: Service() {
return isExpired
}
private fun logout() {
// Update the expiration, assumed the server time and client time is the same
TokenManager.getToken()
// Navigate to login page again
navigateToLogin()
}
private fun navigateToLogin() {
val intent = Intent(this, LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment