logout method

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

Logout and clear stored data

Implementation

Future<void> logout({bool allDevices = false}) async {
  try {
    // Call logout endpoint if token exists
    final accessToken = await _getAccessToken();
    if (accessToken != null) {
      await _apiClient.post(
        '/api/v1/auth/logout',
        data: {
          'allDevices': allDevices,
        },
      );
    }
  } on Exception {
    // Ignore logout API errors, still clear local data
  } finally {
    // Clear all stored data
    await _clearStoredData();

    // Remove authorization headers
    _apiClient
      ..removeAuthToken()
      ..removeOrganization();
  }
}