logout method

Future<void> logout({
  1. bool allDevices = false,
})

Logout

Implementation

Future<void> logout({bool allDevices = false}) async {
  state = const AsyncValue.loading();

  try {
    final client = ref.read(prodobitClientProvider);
    await client.auth.logout(allDevices: allDevices);
    ref.read(otpProvider.notifier).reset();
    state = const AsyncValue.data(AuthState.unauthenticated());
  } on Exception {
    // Even if logout fails, clear local state
    ref.read(otpProvider.notifier).reset();
    state = const AsyncValue.data(AuthState.unauthenticated());
  }
}