From 05b2e1ed0822072b0cd66ec29850aa518ee65081 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 17 Mar 2019 18:43:20 +0100 Subject: [PATCH] Root url. --- .../Controllers/Account/AccountController.cs | 7 +++ src/Squidex/Areas/IdentityServer/Startup.cs | 1 - .../Views/Account/AccessDenied.cshtml | 2 +- .../Views/Account/LockedOut.cshtml | 4 +- .../Views/Account/LogoutCompleted.cshtml | 2 +- .../IdentityServer/Views/Error/Error.cshtml | 2 +- .../Areas/IdentityServer/Views/Extensions.cs | 44 +++++++++++++++++++ .../Views/Profile/Profile.cshtml | 2 +- .../Areas/IdentityServer/Views/_Layout.cshtml | 4 +- .../IdentityServer/Views/_ViewImports.cshtml | 1 + 10 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 src/Squidex/Areas/IdentityServer/Views/Extensions.cs diff --git a/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs b/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs index a7da10ccb..bb95b1cdf 100644 --- a/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs +++ b/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs @@ -57,6 +57,13 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account this.signInManager = signInManager; } + [HttpGet] + [Route("account/error/")] + public IActionResult LoginError() + { + throw new InvalidOperationException(); + } + [HttpGet] [Route("account/forbidden/")] public IActionResult Forbidden() diff --git a/src/Squidex/Areas/IdentityServer/Startup.cs b/src/Squidex/Areas/IdentityServer/Startup.cs index 632a7cbab..e98f0aff3 100644 --- a/src/Squidex/Areas/IdentityServer/Startup.cs +++ b/src/Squidex/Areas/IdentityServer/Startup.cs @@ -34,7 +34,6 @@ namespace Squidex.Areas.IdentityServer identityApp.UseMyIdentityServer(); - identityApp.UseStaticFiles(); identityApp.UseMvc(); }); } diff --git a/src/Squidex/Areas/IdentityServer/Views/Account/AccessDenied.cshtml b/src/Squidex/Areas/IdentityServer/Views/Account/AccessDenied.cshtml index b4e05a554..16aef5862 100644 --- a/src/Squidex/Areas/IdentityServer/Views/Account/AccessDenied.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/Account/AccessDenied.cshtml @@ -3,7 +3,7 @@ ViewBag.Title = "Account locked"; } - +

Access denied

diff --git a/src/Squidex/Areas/IdentityServer/Views/Account/LockedOut.cshtml b/src/Squidex/Areas/IdentityServer/Views/Account/LockedOut.cshtml index 2d36fa027..69afd0b6c 100644 --- a/src/Squidex/Areas/IdentityServer/Views/Account/LockedOut.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/Account/LockedOut.cshtml @@ -2,7 +2,7 @@ ViewBag.Title = "Account locked"; } - +

Account locked

@@ -11,5 +11,5 @@

- Logout + Logout

\ No newline at end of file diff --git a/src/Squidex/Areas/IdentityServer/Views/Account/LogoutCompleted.cshtml b/src/Squidex/Areas/IdentityServer/Views/Account/LogoutCompleted.cshtml index 06b3fee6b..ca6b6702d 100644 --- a/src/Squidex/Areas/IdentityServer/Views/Account/LogoutCompleted.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/Account/LogoutCompleted.cshtml @@ -2,7 +2,7 @@ ViewBag.Title = "Logout"; } - +

Logged out!

diff --git a/src/Squidex/Areas/IdentityServer/Views/Error/Error.cshtml b/src/Squidex/Areas/IdentityServer/Views/Error/Error.cshtml index a95e9f67e..9d5d18176 100644 --- a/src/Squidex/Areas/IdentityServer/Views/Error/Error.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/Error/Error.cshtml @@ -4,7 +4,7 @@ ViewBag.Title = "Error"; } - +

Operation failed

diff --git a/src/Squidex/Areas/IdentityServer/Views/Extensions.cs b/src/Squidex/Areas/IdentityServer/Views/Extensions.cs new file mode 100644 index 000000000..814f9fb2a --- /dev/null +++ b/src/Squidex/Areas/IdentityServer/Views/Extensions.cs @@ -0,0 +1,44 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Squidex.Areas.IdentityServer.Views +{ + public static class Extensions + { + public static string RootContentUrl(this IUrlHelper urlHelper, string contentPath) + { + if (string.IsNullOrEmpty(contentPath)) + { + return null; + } + + if (contentPath[0] == '~') + { + var segment = new PathString(contentPath.Substring(1)); + + var applicationPath = urlHelper.ActionContext.HttpContext.Request.PathBase; + + if (applicationPath.HasValue) + { + var indexOfLastPart = applicationPath.Value.LastIndexOf('/'); + + if (indexOfLastPart >= 0) + { + applicationPath = applicationPath.Value.Substring(0, indexOfLastPart); + } + } + + return applicationPath.Add(segment).Value; + } + + return contentPath; + } + } +} diff --git a/src/Squidex/Areas/IdentityServer/Views/Profile/Profile.cshtml b/src/Squidex/Areas/IdentityServer/Views/Profile/Profile.cshtml index 92cd1bd07..bba833687 100644 --- a/src/Squidex/Areas/IdentityServer/Views/Profile/Profile.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/Profile/Profile.cshtml @@ -26,7 +26,7 @@
- +
diff --git a/src/Squidex/Areas/IdentityServer/Views/_Layout.cshtml b/src/Squidex/Areas/IdentityServer/Views/_Layout.cshtml index 8d4af3196..2760c2247 100644 --- a/src/Squidex/Areas/IdentityServer/Views/_Layout.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/_Layout.cshtml @@ -9,7 +9,7 @@ @ViewBag.Title - Squidex Headless CMS - + @if (IsSectionDefined("header")) @@ -19,7 +19,7 @@
- + @RenderBody()
diff --git a/src/Squidex/Areas/IdentityServer/Views/_ViewImports.cshtml b/src/Squidex/Areas/IdentityServer/Views/_ViewImports.cshtml index 7b56072b2..084f025ef 100644 --- a/src/Squidex/Areas/IdentityServer/Views/_ViewImports.cshtml +++ b/src/Squidex/Areas/IdentityServer/Views/_ViewImports.cshtml @@ -1,3 +1,4 @@ @using Microsoft.AspNetCore.Identity +@using Squidex.Areas.IdentityServer.Views; @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers