@inject NavigationManager Navigation
@inject AuthenticationStateProvider AuthStateProvider

@rendermode InteractiveServer

@code {
    protected override async Task OnInitializedAsync()
    {
        var state = await AuthStateProvider.GetAuthenticationStateAsync();
        if (state.User.Identity?.IsAuthenticated == true)
            return;
        Navigation.NavigateTo("/login");
    }
}
