Remove remnants of the Angular implementation (#16026)

This commit is contained in:
Kenn Jacobsen
2024-04-11 09:08:56 +02:00
committed by GitHub
parent 80c5d28316
commit d47638df98
10 changed files with 4 additions and 91 deletions

View File

@@ -211,7 +211,7 @@ public class ConfigureBackOfficeCookieOptions : IConfigureNamedOptions<CookieAut
{
_securitySettings.AuthCookieName,
Constants.Web.PreviewCookieName, Constants.Security.BackOfficeExternalCookieName,
Constants.Web.AngularCookieName, Constants.Web.CsrfValidationCookieName
Constants.Web.CsrfValidationCookieName
};
foreach (var cookie in cookies)
{

View File

@@ -24,16 +24,6 @@ public static partial class Constants
/// </summary>
public const string CsrfValidationCookieName = "UMB-XSRF-V";
/// <summary>
/// The cookie name that is set for angular to use to pass in to the header value for "X-UMB-XSRF-TOKEN"
/// </summary>
public const string AngularCookieName = "UMB-XSRF-TOKEN";
/// <summary>
/// The header name that angular uses to pass in the token to validate the cookie
/// </summary>
public const string AngularHeadername = "X-UMB-XSRF-TOKEN";
/// <summary>
/// The route name of the page shown when Umbraco has no published content.
/// </summary>

View File

@@ -211,7 +211,7 @@ public class DataValueEditor : IDataValueEditor
case ValueStorageType.Ntext:
case ValueStorageType.Nvarchar:
// If it is a string type, we will attempt to see if it is JSON stored data, if it is we'll try to convert
// to a real JSON object so we can pass the true JSON object directly to Angular!
// to a real JSON object so we can pass the true JSON object directly to the client
var stringValue = value as string ?? value.ToString();
if (stringValue!.DetectIsJson())
{

View File

@@ -5,11 +5,6 @@ namespace Umbraco.Cms.Core.PublishedCache;
/// </summary>
public interface IPublishedSnapshotStatus
{
/// <summary>
/// Gets the URL used to retreive the status
/// </summary>
string StatusUrl { get; }
/// <summary>
/// Gets the status report as a string
/// </summary>

View File

@@ -22,7 +22,6 @@ public class ClearCsrfCookieHandler : INotificationHandler<UmbracoPlanExecutedNo
return;
}
_cookieManager.ExpireCookie(Constants.Web.AngularCookieName);
_cookieManager.ExpireCookie(Constants.Web.CsrfValidationCookieName);
}
}

View File

@@ -17,9 +17,6 @@ internal class PublishedSnapshotStatus : IPublishedSnapshotStatus
_publishedContentService = publishedContentService;
}
/// <inheritdoc />
public virtual string StatusUrl => "views/dashboard/settings/publishedsnapshotcache.html";
/// <inheritdoc />
public string GetStatus()
{

View File

@@ -1,11 +0,0 @@
using System.Net;
using Microsoft.AspNetCore.Mvc;
namespace Umbraco.Cms.Web.Common.ActionsResults;
// TODO: What is the purpose of this? Doesn't seem to add any benefit
public class UmbracoProblemResult : ObjectResult
{
public UmbracoProblemResult(string message, HttpStatusCode httpStatusCode = HttpStatusCode.InternalServerError)
: base(new { Message = message }) => StatusCode = (int)httpStatusCode;
}

View File

@@ -1,53 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.Common.ActionsResults;
// TODO: This should probably follow the same conventions as in aspnet core and use ProblemDetails
// and ProblemDetails factory. See https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Core/src/ControllerBase.cs#L1977
// ProblemDetails is explicitly checked for in the application model.
// In our base class UmbracoAuthorizedApiController the logic is there to create a ProblemDetails.
// However, to do this will require changing how angular deals with errors since the response will
// probably be different. Would just be better to follow the aspnet patterns.
/// <summary>
/// Custom result to return a validation error message with required headers
/// </summary>
/// <remarks>
/// The default status code is a 400 http response
/// </remarks>
public class ValidationErrorResult : ObjectResult
{
public ValidationErrorResult(ModelStateDictionary modelState)
: this(new SimpleValidationModel(modelState.ToErrorDictionary()))
{
}
public ValidationErrorResult(object? value, int statusCode)
: base(value) => StatusCode = statusCode;
public ValidationErrorResult(object? value)
: this(value, StatusCodes.Status400BadRequest)
{
}
// TODO: Like here, shouldn't we use ProblemDetails?
public ValidationErrorResult(string errorMessage, int statusCode)
: base(new { Message = errorMessage }) =>
StatusCode = statusCode;
public ValidationErrorResult(string errorMessage)
: this(errorMessage, StatusCodes.Status400BadRequest)
{
}
public override void OnFormatting(ActionContext context)
{
base.OnFormatting(context);
context.HttpContext.Response.Headers["X-Status-Reason"] = "Validation failed";
}
}

View File

@@ -115,8 +115,7 @@ public class UmbExternalLoginController : SurfaceController
await _memberManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey);
if (attemptedUser == null!)
{
return new ValidationErrorResult(
$"No local user found for the login provider {loginInfo.LoginProvider} - {loginInfo.ProviderKey}");
return BadRequest($"No local user found for the login provider {loginInfo.LoginProvider} - {loginInfo.ProviderKey}");
}
IEnumerable<string> providerNames =

View File

@@ -1,14 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.ActionsResults;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Cms.Web.Common.Models;
using Umbraco.Cms.Web.Common.Security;
@@ -84,8 +82,7 @@ public class UmbLoginController : SurfaceController
MemberIdentityUser? attemptedUser = await _memberManager.FindByNameAsync(model.Username);
if (attemptedUser == null!)
{
return new ValidationErrorResult(
$"No local member found for username {model.Username}");
return BadRequest($"No local member found for username {model.Username}");
}
IEnumerable<string> providerNames =