@inherits LayoutComponentBase
@page "/"

@inject NavigationManager NavigationManager
@using Microsoft.AspNetCore.Identity;
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject UserManager<IdentityUser> UserManager

@*<AuthorizeView>
        <Authorized>
            <div class="blocks">
                <a href="desktop" class="nav__link">Рабочий стол</a>
            </div>
        </Authorized>
        <NotAuthorized>
            <a href="Identity/Account/Login" class="nav__link">Логин</a>
        </NotAuthorized>
    </AuthorizeView>*@


@code{
    protected override async Task OnInitializedAsync()
    {

        var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
        var user = authState.User;

        if (user.Identity.IsAuthenticated)
            NavigationManager.NavigateTo("desktop");
        else
            NavigationManager.NavigateTo("Identity/Account/Login", true);
    }
}