diff --git a/kitchenowl/lib/cubits/auth_cubit.dart b/kitchenowl/lib/cubits/auth_cubit.dart index 573d561b..519e4e3f 100644 --- a/kitchenowl/lib/cubits/auth_cubit.dart +++ b/kitchenowl/lib/cubits/auth_cubit.dart @@ -58,7 +58,15 @@ class AuthCubit extends Cubit<AuthState> { break; case Connection.connected: if (state is AuthenticatedOffline) { - // Keep offline state until successfully authenticated + // Try to authenticate, only stay offline if it fails + try { + if (await ApiService.getInstance().refreshAuth()) { + final user = (await ApiService.getInstance().getUser())!; + emit(Authenticated(user)); + } + } catch (_) { + // Stay offline if auth fails + } return; } if (await ApiService.getInstance().isOnboarding()) {