From 54d1e9d5e0521561cb2de1950720dd3a5ea733d8 Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Tue, 8 Dec 2020 15:36:37 +0100 Subject: [PATCH] Removing AllowsCultureVariation from ContentController, so we can get rid of OverrideAuthorization attribute --- .../Controllers/ContentController.cs | 16 +--------------- .../Controllers/ContentTypeController.cs | 13 +++++++++++++ .../src/common/resources/content.resource.js | 11 +---------- .../src/common/resources/contenttype.resource.js | 9 +++++++++ .../src/navigation.controller.js | 4 ++-- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs index a6f6bc8fb8..b6dcdce14d 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -127,20 +127,6 @@ namespace Umbraco.Web.BackOffice.Controllers _logger = loggerFactory.CreateLogger(); _allLangs = new Lazy>(() => _localizationService.GetAllLanguages().ToDictionary(x => x.IsoCode, x => x, StringComparer.InvariantCultureIgnoreCase)); - - } - - /// - /// Returns true if any content types have culture variation enabled - /// - /// - [HttpGet] - // TODO: We need to move this since we are going to delete OverrideAuthorization - [Authorize(Policy = AuthorizationPolicies.BackOfficeAccess), OverrideAuthorization] - public bool AllowsCultureVariation() - { - var contentTypes = _contentTypeService.GetAll(); - return contentTypes.Any(contentType => contentType.VariesByCulture()); } /// diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index f11ed373cd..9a9404f764 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -255,6 +255,19 @@ namespace Umbraco.Web.BackOffice.Controllers }); return Ok(result); } + + /// + /// Returns true if any content types have culture variation enabled + /// + /// + [HttpGet] + [Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)] + public bool AllowsCultureVariation() + { + IEnumerable contentTypes = _contentTypeService.GetAll(); + return contentTypes.Any(contentType => contentType.VariesByCulture()); + } + /// /// Returns where a particular composition has been used /// This has been wrapped in a dto instead of simple parameters to support having multiple parameters in post request body diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 3dfbeade4f..b6f5d99d9f 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -42,16 +42,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { return { - allowsCultureVariation: function () { - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "contentApiBaseUrl", - "AllowsCultureVariation")), - 'Failed to retrieve variant content types'); - }, - - savePermissions: function (saveModel) { + savePermissions: function (saveModel) { if (!saveModel) { throw "saveModel cannot be null"; } diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index 97bebef062..4a8c65c322 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -361,6 +361,15 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter, loca "HasContentNodes", [{ id: id }])), 'Failed to retrieve indication for whether content type with id ' + id + ' has associated content nodes'); + }, + + allowsCultureVariation: function () { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "contentTypeApiBaseUrl", + "AllowsCultureVariation")), + 'Failed to retrieve variant content types'); } }; } diff --git a/src/Umbraco.Web.UI.Client/src/navigation.controller.js b/src/Umbraco.Web.UI.Client/src/navigation.controller.js index a383c2d44a..37f6ff9733 100644 --- a/src/Umbraco.Web.UI.Client/src/navigation.controller.js +++ b/src/Umbraco.Web.UI.Client/src/navigation.controller.js @@ -9,7 +9,7 @@ * * @param {navigationService} navigationService A reference to the navigationService */ -function NavigationController($scope, $rootScope, $location, $log, $q, $routeParams, $timeout, $cookies, treeService, appState, navigationService, keyboardService, historyService, eventsService, angularHelper, languageResource, contentResource, editorState) { +function NavigationController($scope, $rootScope, $location, $log, $q, $routeParams, $timeout, $cookies, treeService, appState, navigationService, keyboardService, historyService, eventsService, angularHelper, languageResource, contentTypeResource, editorState) { //this is used to trigger the tree to start loading once everything is ready var treeInitPromise = $q.defer(); @@ -380,7 +380,7 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar */ function loadLanguages() { - return contentResource.allowsCultureVariation().then(function (b) { + return contentTypeResource.allowsCultureVariation().then(function (b) { if (b === true) { return languageResource.getAll(); } else {