Refactor and cleanup (#80)

This commit is contained in:
Leendert de Borst
2024-08-30 21:36:16 +02:00
parent 95949508ba
commit 072e63e98f
10 changed files with 39 additions and 67 deletions

View File

@@ -83,30 +83,4 @@
IsLoading = false;
StateHasChanged();
}
/// <summary>
/// Revokes a specific session (refresh token) for the current user.
/// </summary>
/// <param name="id">The unique identifier of the session to revoke.</param>
/// <returns>A task representing the asynchronous operation.</returns>
private async Task RevokeSession(Guid id)
{
try
{
var response = await Http.DeleteAsync($"api/v1/Security/sessions/{id}");
if (response.IsSuccessStatusCode)
{
GlobalNotificationService.AddSuccessMessage("Session revoked successfully.", true);
await OnSessionsChanged.InvokeAsync();
}
else
{
GlobalNotificationService.AddErrorMessage("Failed to revoke session.", true);
}
}
catch (Exception ex)
{
GlobalNotificationService.AddErrorMessage($"Failed to revoke session: {ex.Message}.", true);
}
}
}