diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/AppsController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/AppsController.cs index c2aa8a1701..ffe7ea3260 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/AppsController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/AppsController.cs @@ -1,76 +1,47 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using VirtoCommerce.Platform.Core.Modularity; -using VirtoCommerce.Platform.Security.Authorization; using VirtoCommerce.Platform.Web.Model.Modularity; -namespace VirtoCommerce.Platform.Web.Controllers.Api -{ - [Route("api/platform/apps")] - public class AppsController : Controller - { - private readonly ILocalModuleCatalog _localModuleCatalog; - private readonly IAuthorizationService _authorizationService; - - public AppsController(ILocalModuleCatalog localModuleCatalog, IAuthorizationService authorizationService) - { - _localModuleCatalog = localModuleCatalog ?? throw new ArgumentNullException(nameof(localModuleCatalog)); - _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); - } - - /// - /// Gets the list of available apps, filtered by user permissions. - /// - /// The list of available apps - [HttpGet] - public async Task>> GetApps() - { - - var authorizedApps = new List - { - // Add Commerce Manager by Default - new AppDescriptor - { - Id = "platform", - Title = "Commerce Manager", - Description = "Virto Commerce Platform", - RelativeUrl = "/", - IconUrl = "/images/platform_app.svg" - } - }; - - var applicationList = _localModuleCatalog.Modules.OfType() - .SelectMany(x => x.Apps) - .OrderBy(x => x.Title); +namespace VirtoCommerce.Platform.Web.Controllers.Api; - foreach (var moduleAppInfo in applicationList) - { - if (await AuthorizeAppAsync(moduleAppInfo.Permission)) - { - authorizedApps.Add(new AppDescriptor(moduleAppInfo)); - } - } - - return authorizedApps; +[Route("api/platform/apps")] +public class AppsController : Controller +{ + private readonly ILocalModuleCatalog _localModuleCatalog; - } + public AppsController(ILocalModuleCatalog localModuleCatalog) + { + _localModuleCatalog = localModuleCatalog ?? throw new ArgumentNullException(nameof(localModuleCatalog)); + } - private async Task AuthorizeAppAsync(string permission) - { - if (string.IsNullOrEmpty(permission)) + /// + /// Gets the list of available apps, filtered by user permissions. + /// + /// The list of available apps + [HttpGet] + public IEnumerable GetApps() + { + var apps = _localModuleCatalog.Modules.OfType() + .SelectMany(x => x.Apps) + .Select(x => new AppDescriptor(x)) + .OrderBy(x => x.Title) + .ToList(); + + apps.Insert(0, // Add Commerce Manager by Default + new AppDescriptor { - return true; - } + Id = "platform", + Title = "Commerce Manager", + Description = "Virto Commerce Platform", + RelativeUrl = "/", + IconUrl = "/images/platform_app.svg" + }); - var result = await _authorizationService.AuthorizeAsync(User, null, - new PermissionAuthorizationRequirement(permission)); + return apps; - return result.Succeeded; - } } }