From cdd9540811e429450ec3a065410f55bd20f9f53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ba=C5=9Fak=20ERDEM?= Date: Thu, 27 Jan 2022 01:16:57 +0300 Subject: [PATCH] Check and fix TODOs about authorization --- apps/angular/src/environments/environment.ts | 2 +- .../BasketProductService.cs | 2 +- .../BasketServiceDomainErrorCodes.cs | 1 + .../Localization/BasketService/en.json | 3 ++- .../Localization/BasketService/tr.json | 3 ++- .../Products/ProductAppService.cs | 9 ++++----- .../DbMigrations/IdentityServerDataSeeder.cs | 3 ++- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/angular/src/environments/environment.ts b/apps/angular/src/environments/environment.ts index a5099734..78d67435 100644 --- a/apps/angular/src/environments/environment.ts +++ b/apps/angular/src/environments/environment.ts @@ -13,7 +13,7 @@ export const environment = { redirectUri: baseUrl, clientId: 'Web', //responseType: 'code', - scope: 'offline_access openid profile email phone AccountService IdentityService AdministrationService', + scope: 'offline_access openid profile email phone AccountService IdentityService AdministrationService CatalogService', //requireHttps: true, }, apis: { diff --git a/services/basket/src/EShopOnAbp.BasketService.Application/BasketProductService.cs b/services/basket/src/EShopOnAbp.BasketService.Application/BasketProductService.cs index 0fc0f523..176f039b 100644 --- a/services/basket/src/EShopOnAbp.BasketService.Application/BasketProductService.cs +++ b/services/basket/src/EShopOnAbp.BasketService.Application/BasketProductService.cs @@ -31,6 +31,6 @@ public class BasketProductService : IBasketProductService, ITransientDependency private Task GetProductAsync(Guid productId) { return _productAppService.GetAsync(productId) ?? - throw new UserFriendlyException("Could not find the product!"); //TODO: Business exception with localization; + throw new UserFriendlyException(BasketServiceDomainErrorCodes.ProductNotFound); } } \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/BasketServiceDomainErrorCodes.cs b/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/BasketServiceDomainErrorCodes.cs index b3770c2e..7273e4dd 100644 --- a/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/BasketServiceDomainErrorCodes.cs +++ b/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/BasketServiceDomainErrorCodes.cs @@ -3,5 +3,6 @@ public static class BasketServiceDomainErrorCodes { /* You can add your business exception error codes here, as constants */ + public const string ProductNotFound = "ProductNotFound"; } } diff --git a/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/en.json b/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/en.json index 1cc2658c..f44c9b4a 100644 --- a/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/en.json +++ b/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/en.json @@ -6,6 +6,7 @@ "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.", "Toolbar:Cart": "My Cart", "Toolbar:BasketNotLoaded": "Couldn't Load!", - "Toolbar:CartEmpty": "Cart is Empty!" + "Toolbar:CartEmpty": "Cart is Empty!", + "ProductNotFound": "Could not find the product!" } } diff --git a/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/tr.json b/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/tr.json index db9d4109..fc0fef09 100644 --- a/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/tr.json +++ b/services/basket/src/EShopOnAbp.BasketService.Domain.Shared/Localization/BasketService/tr.json @@ -6,6 +6,7 @@ "LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz.", "Toolbar:Cart": "Sepetim", "Toolbar:BasketNotLoaded": "Sepet Hatası!", - "Toolbar:CartEmpty": "Sepetiniz Boş" + "Toolbar:CartEmpty": "Sepetiniz Boş", + "ProductNotFound": "Bu ürün bulunamadı!" } } \ No newline at end of file diff --git a/services/catalog/src/EShopOnAbp.CatalogService.Application/Products/ProductAppService.cs b/services/catalog/src/EShopOnAbp.CatalogService.Application/Products/ProductAppService.cs index e3d3c2de..eaba471f 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.Application/Products/ProductAppService.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.Application/Products/ProductAppService.cs @@ -11,7 +11,7 @@ using Volo.Abp.Domain.Repositories; namespace EShopOnAbp.CatalogService.Products { - //[Authorize(CatalogServicePermissions.Products.Default)] //TODO: Temporary removed authorization (I needed to use swagger but the auth didn't work) + [Authorize(CatalogServicePermissions.Products.Default)] public class ProductAppService : ApplicationService, IProductAppService { private readonly ProductManager _productManager; @@ -23,18 +23,17 @@ namespace EShopOnAbp.CatalogService.Products _productRepository = productRepository; } - //TODO: Is this method used? public async Task> GetListPagedAsync(PagedAndSortedResultRequestDto input) { var queryable = await _productRepository.GetQueryableAsync(); - + var products = await AsyncExecuter.ToListAsync( queryable .OrderBy(input.Sorting ?? "Name") .Skip(input.SkipCount) .Take(input.MaxResultCount) ); - + var totalCount = await _productRepository.GetCountAsync(); return new PagedResultDto( @@ -71,7 +70,7 @@ namespace EShopOnAbp.CatalogService.Products return ObjectMapper.Map(product); } - //[Authorize(CatalogServicePermissions.Products.Update)] //TODO: Temporary removed authorization (I needed to use swagger but the auth didn't work) + [Authorize(CatalogServicePermissions.Products.Update)] public async Task UpdateAsync(Guid id, UpdateProductDto input) { var product = await _productRepository.GetAsync(id); diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs index c7caf15d..d9810354 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs @@ -261,7 +261,8 @@ namespace EShopOnAbp.IdentityService.DbMigrations { "AccountService", "IdentityService", - "AdministrationService" + "AdministrationService", + "CatalogService" }), grantTypes: new[] {"authorization_code", "LinkLogin", "password"}, secret: "1q2w3e*".Sha256(),