Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Identity service error controller to account module #5085

Merged
merged 6 commits into from
Aug 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System.Threading.Tasks;
using AutoMapper.Internal;
using IdentityServer4.Models;
using IdentityServer4.Services;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Views.Error;
using Volo.Abp.Http;

Expand All @@ -15,13 +18,16 @@ public class ErrorController : AbpController
{
private readonly IIdentityServerInteractionService _interaction;
private readonly IWebHostEnvironment _environment;
private readonly AbpErrorPageOptions _abpErrorPageOptions;

public ErrorController(
IIdentityServerInteractionService interaction,
IWebHostEnvironment environment)
IWebHostEnvironment environment,
IOptions<AbpErrorPageOptions> abpErrorPageOptions)
{
_interaction = interaction;
_environment = environment;
_abpErrorPageOptions = abpErrorPageOptions.Value;
}

public async Task<IActionResult> Index(string errorId)
Expand All @@ -37,11 +43,18 @@ public async Task<IActionResult> Index(string errorId)
errorMessage.ErrorDescription = null;
}

return View("~/Views/Error/Default.cshtml", new AbpErrorViewModel
return View(GetErrorPageUrl(500), new AbpErrorViewModel
realLiangshiwei marked this conversation as resolved.
Show resolved Hide resolved
{
ErrorInfo = new RemoteServiceErrorInfo(errorMessage.Error, errorMessage.ErrorDescription),
HttpStatusCode = 500
});
}

private string GetErrorPageUrl(int statusCode)
{
var page = _abpErrorPageOptions.ErrorViewUrls.GetOrDefault(statusCode.ToString());

return string.IsNullOrWhiteSpace(page) ? "~/Views/Error/Default.cshtml" : page;
}
}
}