@page "/"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;

@inject LoginService loginService

<PageTitle>Gremlin BlazorServer</PageTitle>

<CascadingAuthenticationState>
    <AuthorizeView>
        <Authorized>
            <h1>Hello, @registeredUser.UserName!</h1>
            <p>You can only see this content if you're authorized.</p>
            <button @onclick="SecureMethod">Authorized Only Button</button>
        </Authorized>
        <NotAuthorized>
            <h1>Welcome to Gremlin BlazorServer</h1>
            <h2>Authentication Failure!</h2>
            <p>You're not signed in.</p>
        </NotAuthorized>
    </AuthorizeView>
</CascadingAuthenticationState>

@code {
    private RegisteredUser registeredUser = new();
    private bool IsAuthenticated { get; set; }

    //protected async override Task OnInitializedAsync()
    //{
    //    IsAuthenticated = await Task.Run(() => loginService.ValidateUserAsync(registeredUser));
    //}

    private void SecureMethod()
    {
        
    }
}