diff --git a/app/src/main/java/com/shaarit/core/network/AuthInterceptor.kt b/app/src/main/java/com/shaarit/core/network/AuthInterceptor.kt index 675b0e5..9bd1801 100644 --- a/app/src/main/java/com/shaarit/core/network/AuthInterceptor.kt +++ b/app/src/main/java/com/shaarit/core/network/AuthInterceptor.kt @@ -28,16 +28,17 @@ class AuthInterceptor @Inject constructor( return chain.proceed(original) } - // Remember whether the first token was generated before we knew the server time. If - // so, a 401 is ambiguous: bad secret, or device clock skew pushed `iat` outside - // Shaarli's tolerance. The Date header of the failed response calibrates our clock, - // so retry exactly once with a regenerated token. - val clockWasUnknown = !serverClock.isSynced - + // A 401 is ambiguous: bad secret, or device/server clock skew pushed `iat` + // outside Shaarli's tolerance. The Date header of the failed response is the + // freshest server-clock estimate we have, so retry exactly once with a + // regenerated token, on every 401 — not only when the clock was never synced. + // Previously the retry was gated on `!serverClock.isSynced`, so once an offset + // had been stored (possibly from a stale or proxy-derived Date header) it was + // trusted for the rest of the process and a correct secret could fail forever. var response = chain.proceed(original.withAuth(apiSecret)) serverClock.syncFromResponse(response) - if (response.code == 401 && clockWasUnknown) { + if (response.code == 401) { response.close() response = chain.proceed(original.withAuth(apiSecret)) serverClock.syncFromResponse(response) diff --git a/app/src/main/java/com/shaarit/data/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/shaarit/data/repository/AuthRepositoryImpl.kt index 64f19a1..65795a9 100644 --- a/app/src/main/java/com/shaarit/data/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/shaarit/data/repository/AuthRepositoryImpl.kt @@ -52,8 +52,11 @@ constructor(private val api: ShaarliApi, private val tokenManager: TokenManager) 401, 403 -> Exception( - "HTTP ${e.code()} - Secret API refuse. Copie le champ « Secret API » de " + - "Shaarli (Configuration -> Securite) : ce n'est PAS ton mot de passe " + + "HTTP ${e.code()} - Secret API refuse. L'application a deja reessaye " + + "avec l'horloge du serveur : un 401 persistant signifie que le " + + "secret saisi ne correspond plus a celui affiche ACTUELLEMENT dans " + + "Shaarli. Copie le champ « Secret API » de Shaarli " + + "(Configuration -> Securite) : ce n'est PAS ton mot de passe " + "de connexion. Si tu as utilise « Deconnexion de tous les appareils », " + "le secret a ete regenere et il faut ressaisir le nouveau." ) diff --git a/app/src/main/java/com/shaarit/presentation/auth/LoginScreen.kt b/app/src/main/java/com/shaarit/presentation/auth/LoginScreen.kt index d1b45d6..c2c7539 100644 --- a/app/src/main/java/com/shaarit/presentation/auth/LoginScreen.kt +++ b/app/src/main/java/com/shaarit/presentation/auth/LoginScreen.kt @@ -190,7 +190,7 @@ fun LoginScreen(onLoginSuccess: () -> Unit, viewModel: LoginViewModel = hiltView Spacer(modifier = Modifier.height(24.dp)) Text( text = - "Find your API secret in Shaarli's\n\"Tools\" → \"Configure your Shaarli\"", + "Find your API secret in Shaarli's\n\"Configuration\" → \"Security\" — it is not\nyour login password", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.outline, textAlign = TextAlign.Center, diff --git a/version.properties b/version.properties index 12b7a56..def9473 100644 --- a/version.properties +++ b/version.properties @@ -1,3 +1,3 @@ #Thu Apr 23 19:46:44 2026 -VERSION_NAME=2.14.2 -VERSION_CODE=43 \ No newline at end of file +VERSION_NAME=2.14.3 +VERSION_CODE=44 \ No newline at end of file