@page "/Account/Login/Access"
@using Microsoft.Extensions.Primitives
@using Microsoft.AspNetCore.Antiforgery;

@attribute [RequireAntiforgeryToken]

<div class="w-100 h-100 d-flex flex-column justify-content-center align-items-center">
    <div class="jumbotron">
        <h1>Authorization</h1>

        <p class="lead text-left">Do you want to grant <strong>@ApplicationName</strong> access to your data? (scopes requested: @Scope)</p>

        <form action="api/Authorization/connect/authorize" method="post" >
            <AntiforgeryToken  />
            @foreach (var parameter in HttpContext.Request.HasFormContentType ? (IEnumerable<KeyValuePair<string, StringValues>>)HttpContext.Request.Form : HttpContext.Request.Query)
            {
                <input type="hidden" name="@parameter.Key" value="@parameter.Value" />
            }

            <input class="btn btn-lg btn-success" name="submit.Accept" type="submit" value="Yes" />
            <input class="btn btn-lg btn-danger" name="submit.Deny" type="submit" value="No" />
        </form>
    </div>
</div>

@code {
    [CascadingParameter]
    private HttpContext HttpContext { get; set; } = default!;

    [SupplyParameterFromQuery(Name = "request_app")]
    private string ApplicationName { get; set; } = "";

    [SupplyParameterFromQuery(Name = "request_scope")]
    private string Scope { get; set; } = "";
}
