diff --git a/ios/Platform/Platform/Core/AuthManager.swift b/ios/Platform/Platform/Core/AuthManager.swift index ee220b9..6f3a431 100644 --- a/ios/Platform/Platform/Core/AuthManager.swift +++ b/ios/Platform/Platform/Core/AuthManager.swift @@ -77,6 +77,7 @@ final class AuthManager { currentUser = response.user isLoggedIn = true UserDefaults.standard.set(true, forKey: loggedInKey) + clearWidgetAuth() // Clear previous user's cached data syncCookieToWidget() WidgetCenter.shared.reloadAllTimelines() } diff --git a/ios/Platform/PlatformWidget/PlatformWidget.swift b/ios/Platform/PlatformWidget/PlatformWidget.swift index 6303459..2b44ee0 100644 --- a/ios/Platform/PlatformWidget/PlatformWidget.swift +++ b/ios/Platform/PlatformWidget/PlatformWidget.swift @@ -116,8 +116,15 @@ struct CalorieProvider: TimelineProvider { do { let (data, response) = try await URLSession.shared.data(for: request) - guard let http = response as? HTTPURLResponse, - (200...299).contains(http.statusCode) else { return nil } + guard let http = response as? HTTPURLResponse else { return nil } + + // Session expired — clear stale cookie so we don't retry + if http.statusCode == 401 { + sharedDefaults.removeObject(forKey: "widget_sessionCookie") + return nil + } + + guard (200...299).contains(http.statusCode) else { return nil } return try JSONSerialization.jsonObject(with: data) as? [String: Any] } catch { return nil