using FastEndpoints;
using FrameworkBLL.UserLogin;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.Framework.ResponseStandard;
using GB5Shared.FastEndPoint;
using static GB5Shared.GB5Constant.Constant;
using System.Linq;
namespace FrameworkSL.Endpoints.UserLogin
{
///
/// Force-terminates one or more active sessions by LoginEventLogId.
/// Admin calls this after viewing GetLoggedInUsersForDashboard.
/// Deletes the session rows from MSESSIONSTORE — the next API call from
/// each terminated session receives 401 from SessionHeartbeatMiddleware.
/// GB4 equivalent: POST /fws/Synchronization.svc/ForceLogOut
///
public class ForceLogout : BaseEndpoint>
{
private readonly ILoggedInUsersBLL _bll;
public ForceLogout(ILoggedInUsersBLL bll) => _bll = bll;
public override void Configure()
{
Delete("/UserLogin/ForceLogout");
AllowAnonymous();
}
public class ForceLogoutParameters
{
[FromHeader]
public string Login { get; set; }
///
/// One or more LoginEventLogIds to force-logout.
/// Taken from the EventLogId field in GetLoggedInUsersForDashboard response.
///
[FromBody]
public List LoginEventLogIds { get; set; }
}
protected override string? GetCacheKey(ForceLogoutParameters req, LoginDTO login) => null;
protected override async Task> ExecuteAsync(
ForceLogoutParameters req, LoginDTO login, CancellationToken ct)
{
if (login is null)
return await GB5Shared.ResponseStandard.Response.CreateErrorResponse