Skip to content

Commit

Permalink
fix: prevent incorrect offline->online transitions without successful…
Browse files Browse the repository at this point in the history
… auth
  • Loading branch information
irishrain committed Jan 4, 2025
1 parent 1d90e65 commit 83b10ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion kitchenowl/lib/cubits/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 83b10ac

Please sign in to comment.