// Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. using eShopOnContainers.Identity; using Identity.API.Services; using IdentityServer4.Quickstart.UI.Models; using IdentityServer4.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using System.Threading.Tasks; namespace IdentityServer4.Quickstart.UI.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); } } }