Updated RefreshResponse field names and token handling

The `RefreshResponse` data class has been updated to use `access_token` and `refresh_token` to match the API response. Consequently, `MainViewModel` now uses these updated field names when saving new tokens to storage. Debug print statements for access and refresh tokens have also been removed.
This commit is contained in:
2026-02-27 22:21:13 +01:00
parent f01357987c
commit 552f604200
2 changed files with 3 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ data class LoginUser(val id: String, val username: String, val role: String, val
data class LoginResponse(val access_token: String, val refresh_token: String, val user: LoginUser, val wgName: String)
data class RefreshRequest(val refresh_token: String)
data class RefreshResponse(val accessToken: String, val refreshToken: String)
data class RefreshResponse(val access_token: String, val refresh_token: String)
interface APIService {
@POST("api/login")

View File

@@ -38,7 +38,6 @@ class MainViewModel(private val accountDao: AccountDao, private val tokenStorage
return@launch
}
println("Testing with AT $accessToken")
val pingResponse = api.ping("Bearer $accessToken")
if(pingResponse.isSuccessful) {
@@ -47,7 +46,6 @@ class MainViewModel(private val accountDao: AccountDao, private val tokenStorage
}
if(pingResponse.code() == 401) {
println("Testing with RT $refreshToken")
val refreshResponse = api.refresh(RefreshRequest(refreshToken))
if(refreshResponse.isSuccessful) {
@@ -55,8 +53,8 @@ class MainViewModel(private val accountDao: AccountDao, private val tokenStorage
tokenStorage.saveTokens(
account.id.toString(),
newTokens.accessToken,
newTokens.accessToken
newTokens.access_token,
newTokens.access_token
)
sessionState = SessionState.Valid