Initial stage of getting rid of HttpResponseException and replacing it with the usage of ValidationErrorResult
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -27,7 +26,6 @@ using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
using Umbraco.Web.Common.Controllers;
|
||||
using Umbraco.Web.Common.Exceptions;
|
||||
using Umbraco.Web.Common.Filters;
|
||||
using Umbraco.Web.Common.Security;
|
||||
using Umbraco.Web.Models;
|
||||
@@ -151,7 +149,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (result.Succeeded == false)
|
||||
{
|
||||
throw HttpResponseException.CreateNotificationValidationErrorResponse(result.Errors.ToErrorMessage());
|
||||
return ValidationErrorResult.CreateNotificationValidationErrorResult(result.Errors.ToErrorMessage());
|
||||
}
|
||||
|
||||
await _signInManager.SignOutAsync();
|
||||
@@ -207,7 +205,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
else
|
||||
{
|
||||
AddModelErrors(result);
|
||||
throw HttpResponseException.CreateValidationErrorResponse(ModelState);
|
||||
return new ValidationErrorResult(ModelState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +348,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
// by our angular helper because it thinks that we need to re-perform the request once we are
|
||||
// authorized and we don't want to return a 403 because angular will show a warning message indicating
|
||||
// that the user doesn't have access to perform this function, we just want to return a normal invalid message.
|
||||
throw new HttpResponseException(HttpStatusCode.BadRequest);
|
||||
return new ValidationErrorResult(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -468,7 +466,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
throw HttpResponseException.CreateValidationErrorResponse(ModelState);
|
||||
return new ValidationErrorResult(ModelState);
|
||||
}
|
||||
|
||||
var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
||||
|
||||
Reference in New Issue
Block a user