Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
only show home page (and error description) in development #2211
Browse files Browse the repository at this point in the history
  • Loading branch information
brockallen committed Apr 11, 2018
1 parent 40c5b66 commit e85465c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
19 changes: 17 additions & 2 deletions src/Host/Quickstart/Home/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using IdentityServer4.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

Expand All @@ -14,15 +15,23 @@ namespace IdentityServer4.Quickstart.UI
public class HomeController : Controller
{
private readonly IIdentityServerInteractionService _interaction;
private readonly IHostingEnvironment _environment;

public HomeController(IIdentityServerInteractionService interaction)
public HomeController(IIdentityServerInteractionService interaction, IHostingEnvironment environment)
{
_interaction = interaction;
_environment = environment;
}

public IActionResult Index()
{
return View();
if (_environment.IsDevelopment())
{
// only show in development
return View();
}

return NotFound();
}

/// <summary>
Expand All @@ -37,6 +46,12 @@ public async Task<IActionResult> Error(string errorId)
if (message != null)
{
vm.Error = message;

if (!_environment.IsDevelopment())
{
// only show in development
message.ErrorDescription = null;
}
}

return View("Error", vm);
Expand Down
2 changes: 1 addition & 1 deletion src/Host/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="welcome-page">
<div class="welcome-page">
<div class="row page-header">
<div class="col-sm-10">
<h1>
Expand Down
4 changes: 1 addition & 3 deletions src/Host/Views/Shared/Error.cshtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
@using Microsoft.AspNetCore.Hosting
@model ErrorViewModel
@inject IHostingEnvironment host

@{
var error = Model?.Error?.Error;
var errorDescription = host.IsDevelopment() ? Model?.Error?.ErrorDescription : null;
var errorDescription = Model?.Error?.ErrorDescription;
var request_id = Model?.Error?.RequestId;
}

Expand Down

0 comments on commit e85465c

Please sign in to comment.