-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved endpoint to new controller to avoid issue with too hard access …
…requirements (#11264) * Fixed #11258 Moved endpoint and obsoleted the old one to avoid breaking changes.. The issue is the auth policies cannot be overridden.. You need all of them, and the controller requires you to have access to member types * Update src/Umbraco.Web.BackOffice/Controllers/MemberTypeQueryController.cs Co-authored-by: Nikolaj Geisle <[email protected]> Co-authored-by: Nikolaj Geisle <[email protected]>
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Umbraco.Web.BackOffice/Controllers/MemberTypeQueryController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Umbraco.Cms.Core.Mapping; | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Cms.Core.Models.ContentEditing; | ||
using Umbraco.Cms.Core.Services; | ||
using Umbraco.Cms.Web.Common.Attributes; | ||
using Umbraco.Cms.Web.Common.Authorization; | ||
using Constants = Umbraco.Cms.Core.Constants; | ||
|
||
namespace Umbraco.Cms.Web.BackOffice.Controllers | ||
{ | ||
/// <summary> | ||
/// An API controller used for dealing with member types | ||
/// </summary> | ||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)] | ||
[Authorize(Policy = AuthorizationPolicies.TreeAccessMembersOrMemberTypes)] | ||
public class MemberTypeQueryController : BackOfficeNotificationsController | ||
{ | ||
private readonly IMemberTypeService _memberTypeService; | ||
private readonly IUmbracoMapper _umbracoMapper; | ||
|
||
|
||
public MemberTypeQueryController( | ||
IMemberTypeService memberTypeService, | ||
IUmbracoMapper umbracoMapper) | ||
{ | ||
_memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); | ||
_umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all member types | ||
/// </summary> | ||
public IEnumerable<ContentTypeBasic> GetAllTypes() => | ||
_memberTypeService.GetAll() | ||
.Select(_umbracoMapper.Map<IMemberType, ContentTypeBasic>); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters