list method
Lists all sessions for the current user.
Returns an AuthResponse containing a list of all Session objects associated with the current user account.
Example:
final response = await authClient.session.list();
if (response.isSuccess) {
for (final session in response.data!) {
print('Session: ${session.id} (${session.ipAddress})');
}
}
Implementation
Future<AuthResponse<List<Session>>> list() async {
try {
final response = await _dio.get(ApiEndpoints.listSessions);
final sessions = (response.data['sessions'] as List)
.map((s) => Session.fromJson(s))
.toList();
return AuthResponse.success(sessions);
} on DioException catch (e) {
return AuthResponse.error(AuthError.fromDio(e));
}
}