示例#1
0
        private async Task <Sequence> SetSequanceAsync(HttpContext httpContext, string routeAction)
        {
            var sequenceString = routeAction.Substring(1);
            var sequence       = await sequenceLogic.TryReadSequenceAsync(sequenceString);

            httpContext.Items[Constants.Routes.SequenceStringKey] = sequenceString;

            return(sequence);
        }
示例#2
0
        public async Task <IActionResult> Index()
        {
            var errorViewModel = new ErrorViewModel
            {
                CreateTime = DateTimeOffset.Now,
                RequestId  = HttpContext.TraceIdentifier
            };

            var exceptionHandlerPathFeature = HttpContext.Features.Get <IExceptionHandlerPathFeature>();
            var exception = exceptionHandlerPathFeature?.Error;

            if (exceptionHandlerPathFeature != null && exceptionHandlerPathFeature.Path.EndsWith($"/{Constants.Routes.OAuthController}/{Constants.Endpoints.Token}", StringComparison.OrdinalIgnoreCase))
            {
                return(HandleOAuthTokenException(exception));
            }

            if (RouteBinding != null && !exceptionHandlerPathFeature.Path.IsNullOrEmpty())
            {
                try
                {
                    var sequenceStartIndex = exceptionHandlerPathFeature.Path.IndexOf('_') + 1;
                    if (exceptionHandlerPathFeature.Path.Length > sequenceStartIndex)
                    {
                        var sequence = await sequenceLogic.TryReadSequenceAsync(exceptionHandlerPathFeature.Path.Substring(sequenceStartIndex));

                        if (sequence != null)
                        {
                            var uiLoginUpParty = await tenantRepository.GetAsync <UiLoginUpPartyData>(sequence.UiUpPartyId);

                            securityHeaderLogic.AddImgSrc(uiLoginUpParty.IconUrl);
                            securityHeaderLogic.AddImgSrcFromCss(uiLoginUpParty.Css);
                            errorViewModel.Title   = uiLoginUpParty.Title;
                            errorViewModel.IconUrl = uiLoginUpParty.IconUrl;
                            errorViewModel.Css     = uiLoginUpParty.Css;
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }

            var sequenceTimeoutException = FindException <SequenceTimeoutException>(exception);

            if (sequenceTimeoutException != null)
            {
                return(HandleSequenceTimeoutException(errorViewModel, sequenceTimeoutException));
            }

            var routeCreationException = FindException <RouteCreationException>(exception);

            if (routeCreationException != null)
            {
                return(HandleRouteCreationException(errorViewModel, routeCreationException));
            }

            var externalKeyIsNotReadyException = FindException <ExternalKeyIsNotReadyException>(exception);

            if (externalKeyIsNotReadyException != null)
            {
                return(HandleexternalKeyIsNotReadyException(errorViewModel));
            }

            if (environment.IsDevelopment())
            {
                errorViewModel.TechnicalErrors = new List <string>(exception.ToString().Split('\n'));
            }
            else
            {
                errorViewModel.TechnicalErrors = exception.GetAllMessages();
            }
            return(View(errorViewModel));
        }