fix(#688): route expired auth sessions to sign-in (#689)

* fix(#688): route expired auth sessions to sign-in

Adopt global 401 latch, WS disconnect, and Back/profile guards.

* chore: clean up formatting noise

* fix(ktlint): reorder imports to place java and kotlinx at end

* fix(ktlint): place java.io.IOException at end of imports

* test: fix NavBackStack type parameter in AuthenticationRoutingTest

* test: add AuthSessionState tests to AuthLoginViewModelTest

* fix(ktlint): fix import order in AuthLoginViewModelTest
This commit is contained in:
M57 authored and GitHub committed 2026-07-23 00:44:17 +03:00
1 parent def122ab58
commit a5baf41545
10 files changed
+217 -4

No files matched your search

@@ -8,6 +8,7 @@ import com.m57.hermescontrol.R
import com.m57.hermescontrol.data.config.ConnectionProfile
import com.m57.hermescontrol.data.config.resolveBaseUrl
import com.m57.hermescontrol.data.local.AuthManager
import com.m57.hermescontrol.data.local.AuthSessionState
import com.m57.hermescontrol.data.remote.ApiClient
import com.m57.hermescontrol.data.remote.CleartextPolicy
import com.m57.hermescontrol.data.remote.NetworkError
@@ -115,7 +116,7 @@ class ConnectViewModel(
val result =
withContext(Dispatchers.IO) {
val tempApi = ApiClient.createTempService(endpoint.baseUrl.toString(), state.token)
safeApiCall { tempApi.getStatus() }
safeApiCall(reportAuthExpiry = false) { tempApi.getStatus() }
}
when (result) {
is NetworkResult.Success -> {
@@ -123,6 +124,7 @@ class ConnectViewModel(
AuthManager.setToken(state.token)
AuthManager.setBaseUrl(state.baseUrl)
ApiClient.rebuild()
AuthSessionState.markAuthenticated()
if (state.saveProfile) {
val currentProfiles = AuthManager.getConnectionProfiles()