Files
aliasvault/apps/server/AliasVault.Client/Auth/Pages/Logout.razor
2025-04-30 19:03:18 +02:00

43 lines
1.5 KiB
Plaintext

@page "/user/logout"
@attribute [AllowAnonymous]
@layout EmptyLayout
@inject AuthenticationStateProvider AuthStateProvider
@inject NavigationManager NavigationManager
@inject AuthService AuthService
@inject GlobalNotificationService GlobalNotificationService
@inject DbService DbService
<div class="fixed inset-0 flex flex-col items-center justify-center px-6 pt-8 pb-8 h-full w-full">
<div class="relative p-6 sm:p-8 bg-white dark:bg-gray-700 rounded-lg sm:shadow-xl max-w-md w-full mx-auto">
<div class="text-center">
<div class="space-y-4">
<BoldLoadingIndicator />
<h2 class="text-xl font-semibold text-gray-900 dark:text-white">Logging out</h2>
<p class="text-sm text-gray-500 dark:text-gray-400">
Securely unloading your data and logging you out. Please wait.
</p>
</div>
</div>
</div>
</div>
@code {
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await AuthService.RemoveTokensAsync();
AuthService.RemoveEncryptionKey();
await AuthStateProvider.GetAuthenticationStateAsync();
// Initialize a new empty database to clear all data.
DbService.InitializeEmptyDatabase();
GlobalNotificationService.ClearMessages();
await Task.Delay(500);
// Redirect to home page
NavigationManager.NavigateTo("/");
}
}