41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
|
2 years ago
|
// Copyright (c) Duende Software. All rights reserved.
|
||
|
|
// See LICENSE in the project root for license information.
|
||
|
|
|
||
|
|
using Duende.IdentityServer.Services;
|
||
|
|
using Microsoft.AspNetCore.Authorization;
|
||
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||
|
|
|
||
|
|
namespace Yavsc.Pages.Error;
|
||
|
|
|
||
|
|
[AllowAnonymous]
|
||
|
|
[SecurityHeaders]
|
||
|
|
public class Index : PageModel
|
||
|
|
{
|
||
|
|
private readonly IIdentityServerInteractionService _interaction;
|
||
|
|
private readonly IWebHostEnvironment _environment;
|
||
|
|
|
||
|
|
public ViewModel View { get; set; } = new();
|
||
|
|
|
||
|
|
public Index(IIdentityServerInteractionService interaction, IWebHostEnvironment environment)
|
||
|
|
{
|
||
|
|
_interaction = interaction;
|
||
|
|
_environment = environment;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task OnGet(string? errorId)
|
||
|
|
{
|
||
|
|
// retrieve error details from identityserver
|
||
|
|
var message = await _interaction.GetErrorContextAsync(errorId);
|
||
|
|
if (message != null)
|
||
|
|
{
|
||
|
|
View.Error = message;
|
||
|
|
|
||
|
|
if (!_environment.IsDevelopment())
|
||
|
|
{
|
||
|
|
// only show in development
|
||
|
|
message.ErrorDescription = null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|