// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.

using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.ComponentModel.DataAnnotations;

namespace Healox.PermissionServer.Sample.IdentityServer.Pages.Ciba
{
    [SecurityHeaders]
    [Authorize]
    public class AllModel : PageModel
    {
        public IEnumerable<BackchannelUserLoginRequest> Logins { get; set; }

        [BindProperty, Required]
        public string Id { get; set; }
        [BindProperty, Required]
        public string Button { get; set; }

        private readonly IBackchannelAuthenticationInteractionService _backchannelAuthenticationInteraction;

        public AllModel(IBackchannelAuthenticationInteractionService backchannelAuthenticationInteractionService)
        {
            _backchannelAuthenticationInteraction = backchannelAuthenticationInteractionService;
        }

        public async Task OnGet()
        {
            Logins = await _backchannelAuthenticationInteraction.GetPendingLoginRequestsForCurrentUserAsync();
        }
    }
}