using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Tiku.Application.Security;

namespace Tiku.Api.Controllers;

[ApiController]
[ApiExplorerSettings(IgnoreApi = true)]
[Route("api/_security")]
public sealed class SecurityDiagnosticsController(
    ICurrentUser currentUser,
    ITenantContext currentTenant) : ControllerBase
{
    [Authorize(Policy = TikuPolicies.AuthenticatedUser)]
    [HttpGet("authenticated")]
    public ActionResult<object> Authenticated()
    {
        return Ok(new
        {
            currentUser.UserId,
            currentUser.IsAuthenticated
        });
    }

    [Authorize(Policy = TikuPolicies.CurrentTenantMember)]
    [HttpGet("tenant-member")]
    public ActionResult<object> TenantMember()
    {
        return Ok(new
        {
            currentTenant.TenantId
        });
    }

    [Authorize(Policy = TikuPolicies.TenantAdmin)]
    [HttpGet("tenant-admin")]
    public ActionResult<object> TenantAdmin()
    {
        return Ok(new
        {
            currentTenant.TenantId
        });
    }
}
