using JetBrains.Annotations; using Microsoft.AspNetCore.Authorization; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices.ComTypes; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Authorization; namespace Volo.CmsKit.Admin; public abstract class CmsKitAdminAppServiceBase : CmsKitAppServiceBase { protected CmsKitAdminAppServiceBase() { ObjectMapperContext = typeof(CmsKitAdminApplicationModule); } /// /// Checks given policies until finding granted policy. If none of them is granted, throws /// /// Policies to be checked. /// Thrown when none of policies is granted. protected async Task CheckAnyOfPoliciesAsync([NotNull] IEnumerable policies) { Check.NotNull(policies, nameof(policies)); foreach (var policy in policies) { if (await AuthorizationService.IsGrantedAsync(policy)) { return; } } throw new AbpAuthorizationException(); } }