public async Task <ActionResult> Cancel(BankIdLoginApiCancelRequest request) { if (string.IsNullOrWhiteSpace(request.LoginOptions)) { throw new ArgumentNullException(nameof(request.LoginOptions)); } if (request.OrderRef == null) { throw new ArgumentNullException(nameof(request.OrderRef)); } var unprotectedLoginOptions = _loginOptionsProtector.Unprotect(request.LoginOptions); var orderRef = _orderRefProtector.Unprotect(request.OrderRef); var detectedDevice = GetDetectedUserDevice(); try { await _bankIdApiClient.CancelAsync(orderRef.OrderRef); await _bankIdEventTrigger.TriggerAsync(new BankIdCancelSuccessEvent(orderRef.OrderRef, detectedDevice, unprotectedLoginOptions)); } catch (BankIdApiException exception) { // When we get exception in a cancellation request, chances // are that the orderRef has already been cancelled or we have // a network issue. We still want to provide the GUI with the // validated cancellation URL though. await _bankIdEventTrigger.TriggerAsync(new BankIdCancelErrorEvent(orderRef.OrderRef, exception, detectedDevice, unprotectedLoginOptions)); } return(OkJsonResult(BankIdLoginApiCancelResponse.Cancelled())); }
public async Task <ActionResult> Cancel(BankIdLoginApiCancelRequest request) { if (request.OrderRef == null) { throw new ArgumentNullException(nameof(request.OrderRef)); } if (request.CancelReturnUrl == null) { throw new ArgumentNullException(nameof(request.CancelReturnUrl)); } if (!Url.IsLocalUrl(request.CancelReturnUrl)) { throw new Exception(BankIdConstants.InvalidCancelReturnUrlErrorMessage); } var orderRef = _orderRefProtector.Unprotect(request.OrderRef); await _bankIdApiClient.CancelAsync(orderRef.OrderRef); _logger.BankIdAuthCancelled(orderRef.OrderRef); return(Ok(BankIdLoginApiCancelResponse.Cancelled(request.CancelReturnUrl))); }
public async Task <ActionResult> Cancel(BankIdLoginApiCancelRequest request) { var orderRef = _orderRefProtector.Unprotect(request.OrderRef); await _bankIdApiClient.CancelAsync(orderRef.OrderRef); _logger.BankIdAuthCancelled(orderRef.OrderRef); return(Ok(BankIdLoginApiCancelResponse.Cancelled())); }
public async Task <ActionResult> Cancel(BankIdLoginApiCancelRequest request) { if (request.OrderRef == null) { throw new ArgumentNullException(nameof(request.OrderRef)); } if (request.CancelReturnUrl == null) { throw new ArgumentNullException(nameof(request.CancelReturnUrl)); } if (!Url.IsLocalUrl(request.CancelReturnUrl)) { throw new Exception(BankIdConstants.InvalidCancelReturnUrlErrorMessage); } var orderRef = _orderRefProtector.Unprotect(request.OrderRef); try { await _bankIdApiClient.CancelAsync(orderRef.OrderRef); _logger.BankIdCancelSuccess(orderRef.OrderRef); } catch (Exception exception) { // When we get exception in a cancellation request, chances // are that the orderRef has already been cancelled or we have // a network issue. We still want to provide the GUI with the // validated cancellation URL though. _logger.BankIdCancelFailed(orderRef.OrderRef, exception.Message); } return(Ok(BankIdLoginApiCancelResponse.Cancelled(request.CancelReturnUrl))); }