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

This reverts commit a5baf41545.
This commit is contained in:
M57 authored and GitHub committed 2026-07-23 12:40:29 +03:00
1 parent bc6c8a2e68
commit 7927944198
10 files changed
+4 -217

No files matched your search

@@ -1,31 +0,0 @@
package com.m57.hermescontrol.data.local
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
/**
* Single source of truth for app-wide auth session expiry latch.
* When a REST call returns 401 (AuthExpired), [requireSignIn] is invoked,
* triggering central navigation reset to [AuthLoginScreen] and WS disconnect.
*/
object AuthSessionState {
private val _signInRequired = MutableStateFlow(false)
val signInRequired: StateFlow<Boolean> = _signInRequired.asStateFlow()
fun requireSignIn() {
_signInRequired.value = true
}
fun markAuthenticated() {
_signInRequired.value = false
}
fun clearSignInRequired() {
_signInRequired.value = false
}
fun resetForTest() {
_signInRequired.value = false
}
}
@@ -1,6 +1,5 @@
package com.m57.hermescontrol.data.remote
import com.m57.hermescontrol.data.local.AuthSessionState
import kotlinx.coroutines.delay
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
@@ -91,7 +90,6 @@ fun jitteredBackoff(baseMs: Long): Long {
suspend inline fun <reified T> safeApiCall(
retries: Int = 2,
reportAuthExpiry: Boolean = true,
crossinline call: suspend () -> Response<T>,
): NetworkResult<T> {
var lastException: IOException? = null
@@ -120,11 +118,7 @@ suspend inline fun <reified T> safeApiCall(
delay(backoff)
continue
}
val failure = NetworkResult.Failure(mapHttpError(code, errorBody))
if (reportAuthExpiry && failure.error is NetworkError.AuthExpired) {
AuthSessionState.requireSignIn()
}
return failure
return NetworkResult.Failure(mapHttpError(code, errorBody))
}
} catch (e: IOException) {
lastException = e