Пример #1
0
        public async Task <IActionResult> CancelLimitOrder(string orderId)
        {
            var tradingSession = await _clientSessionsClient.GetTradingSession(_lykkePrincipal.GetToken());

            var confirmationRequired = _baseSettings.EnableSessionValidation && !(tradingSession?.Confirmed ?? false);

            if (confirmationRequired)
            {
                return(BadRequest("Session confirmation is required"));
            }

            var clientId = _requestContext.ClientId;

            var activeOrders = await _limitOrdersRepository.GetActiveByClientIdAsync(clientId);

            if (activeOrders.All(x => x.Id != orderId))
            {
                return(NotFound());
            }

            await _limitOrdersRepository.CancelByIdAsync(orderId);

            await _matchingEngineClient.CancelLimitOrderAsync(orderId);

            return(Ok());
        }
Пример #2
0
        public async Task <IActionResult> LogOut()
        {
            var token = _lykkePrincipal.GetToken();

            var session = await _clientSessionsClient.GetAsync(token);

            if (session != null)
            {
                await _clientSessionsClient.DeleteSessionIfExistsAsync(session.SessionToken);
            }

            return(Ok());
        }
        public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
        {
            var logFactory = context.HttpContext.RequestServices.GetService <ILogFactory>();

            _log            = logFactory.CreateLog(this);
            _lykkePrincipal = context.HttpContext.RequestServices.GetService <ILykkePrincipal>();

            try
            {
                var principal = await _lykkePrincipal.GetCurrentAsync();

                if (principal == null)
                {
                    context.Result = new UnauthorizedObjectResult(new { Error = "Not authenticated" });
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex, context: _lykkePrincipal.GetToken());
            }
        }