using IdentityServer4.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.eShopOnContainers.Services.Identity.API.Models; using Microsoft.eShopOnContainers.Services.Identity.API.Services; using Microsoft.Extensions.Options; using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers { public class HomeController : Controller { private readonly IIdentityServerInteractionService _interaction; private readonly IOptionsSnapshot _settings; private readonly IRedirectService _redirectSvc; public HomeController(IIdentityServerInteractionService interaction, IOptionsSnapshot settings, IRedirectService redirectSvc) { _interaction = interaction; _settings = settings; _redirectSvc = redirectSvc; } public IActionResult Index(string returnUrl) { return View(); } public IActionResult ReturnToOriginalApplication(string returnUrl) { if (returnUrl != null) return Redirect(_redirectSvc.ExtractRedirectUriFromReturnUrl(returnUrl)); else return RedirectToAction("Index", "Home"); } /// /// Shows the error page /// public async Task Error(string errorId) { var vm = new ErrorViewModel(); // retrieve error details from identityserver var message = await _interaction.GetErrorContextAsync(errorId); if (message != null) { vm.Error = message; } return View("Error", vm); } } }