From e825d6938dc1dc2b9efcb7cc7f2b8e44533bc87f Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 7 Dec 2025 22:49:19 -0800 Subject: [PATCH] fix(mobile-app): don't clear auth data on token refresh failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid clearing user's auth data when token refresh fails due to network errors or other transient issues. Only clear on explicit refresh token expiration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- frontend/mobile-app/lib/core/network/api_client.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/mobile-app/lib/core/network/api_client.dart b/frontend/mobile-app/lib/core/network/api_client.dart index 3c2d90d2..f39bb6d5 100644 --- a/frontend/mobile-app/lib/core/network/api_client.dart +++ b/frontend/mobile-app/lib/core/network/api_client.dart @@ -106,13 +106,13 @@ class ApiClient { final response = await _retryRequest(error.requestOptions); return handler.resolve(response); } else { - debugPrint('Token refresh failed, clearing auth data...'); - await _clearAuthData(); + // refresh token 不存在,不清除数据,让用户重新登录 + debugPrint('Token refresh failed: no refresh token available'); } } catch (e) { debugPrint('Token refresh exception: $e'); - // 刷新失败,清除登录状态 - await _clearAuthData(); + // 只有当 refresh token 明确过期(401)时才清除数据 + // 其他错误(如网络错误)不清除,避免误清除 } }