@page "/user/logout"
@attribute [AllowAnonymous]
@layout Auth.Layout.MainLayout
@inject AuthenticationStateProvider AuthStateProvider
@inject NavigationManager NavigationManager
@inject AuthService AuthService
@inject GlobalNotificationService GlobalNotificationService
@using AliasVault.WebApp.Auth.Services

@code {
    /// <inheritdoc />
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        await AuthService.RemoveTokensAsync();
        await AuthStateProvider.GetAuthenticationStateAsync();
        GlobalNotificationService.ClearMessages();

        // Redirect to home page
        NavigationManager.NavigateTo("/");
    }
}
