Merge pull request #8598 from umbraco/netcore/feature/6972-migrate-non-oauth-auth-controller
Migrates remaining non-oauth AuthenticationController actions to netcore
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Umbraco.Web.Common.ActionsResults
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom result to return a validation error message with a 400 http response and required headers
|
||||
/// </summary>
|
||||
public class ValidationErrorResult : ObjectResult
|
||||
{
|
||||
public ValidationErrorResult(string errorMessage) : base(new { Message = errorMessage })
|
||||
{
|
||||
StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
}
|
||||
|
||||
public override void OnFormatting(ActionContext context)
|
||||
{
|
||||
base.OnFormatting(context);
|
||||
context.HttpContext.Response.Headers["X-Status-Reason"] = "Validation failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user