From 04032a6dbc1c946a2bc89b295192927002ef9c58 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Mon, 5 Jan 2026 10:16:43 +0100 Subject: [PATCH] fix(auth): remove auto-signout on 401 in AuthInterceptor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The AuthInterceptor was calling signOut() on any 401 error, which caused the theme toggle to trigger logout when the preferences API returned 401. Now 401 errors propagate to calling code for graceful handling. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 8 ++++++++ lib/core/api/api_interceptors.dart | 13 +++---------- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a167666..d8d8b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.16] - 2026-01-05 + +### Fixed +- Theme toggle causing logout due to AuthInterceptor auto-signout on 401 + - Removed aggressive `signOut()` call in `AuthInterceptor.onError` + - 401 errors now propagate to calling code for graceful handling + - Preferences API 401 no longer triggers full logout redirect + ## [1.1.15] - 2026-01-05 ### Fixed diff --git a/lib/core/api/api_interceptors.dart b/lib/core/api/api_interceptors.dart index 7be3d50..3fd19d2 100644 --- a/lib/core/api/api_interceptors.dart +++ b/lib/core/api/api_interceptors.dart @@ -38,16 +38,9 @@ class AuthInterceptor extends Interceptor { @override void onError(DioException err, ErrorInterceptorHandler handler) { - // Skip auth error handling for LAN development - if (!AppConfig.requiresAuth) { - handler.next(err); - return; - } - - if (err.response?.statusCode == 401) { - // Token expired - trigger re-authentication - _ref.read(authProvider.notifier).signOut(); - } + // Don't auto-signout on 401 - let calling code handle auth errors gracefully. + // Auto-signout was causing issues (e.g., theme toggle triggering logout when + // preferences API returned 401). handler.next(err); } } diff --git a/pubspec.yaml b/pubspec.yaml index 4cba042..493db91 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.15+1 +version: 1.1.16+1 environment: sdk: ^3.10.4