using DXPBLL.Auth; using DXPDAL.Common; using DXPSL.Common; using DXPSL.Parameters.Auth; using GB5Shared.DTO.Framework.Enum; using GB5Shared.DTO.Framework.ResponseStandard; namespace DXPSL.Endpoints.Auth; // Protected — requires the intermediate JWT issued by Login when the user has more than one // context. Reads DxpUserId from the verified token via DXPCallerContext, never from the body. public class ContextSwitch : DXPBaseEndpoint> { private readonly IAuthBLL _bll; private readonly IDXPSystemContext _systemContext; public ContextSwitch(IAuthBLL bll, IDXPSystemContext systemContext) { _bll = bll; _systemContext = systemContext; } public override void Configure() { Post("/DXP/Auth/ContextSwitch"); } protected override async Task> ExecuteAsync( ContextSwitchParameters req, DXPCallerContext caller, CancellationToken ct) { var tokens = await _bll.ContextSwitchAsync( caller.DxpUserId, req.DxpUserPartyRoleId, req.DxpPartyLinkId, req.DeviceInfo, _systemContext.GetSystemLogin(caller.DxpUserId), ct); return new ResponseStandardDTO { Status = FrameworkEnumDTO.ResponseStatus.Ok, Body = tokens }; } }