From 4fee0f5bdee899d58c2f123305574ec1a2c3c2f6 Mon Sep 17 00:00:00 2001 From: Brian Talma <47258865+btalma@users.noreply.github.com> Date: Tue, 24 Jan 2023 14:59:59 -0500 Subject: [PATCH 1/2] Update RoutesController.cs --- dotnet/Controlers/RoutesController.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/dotnet/Controlers/RoutesController.cs b/dotnet/Controlers/RoutesController.cs index 6a4f3ef..1b1f96b 100644 --- a/dotnet/Controlers/RoutesController.cs +++ b/dotnet/Controlers/RoutesController.cs @@ -1,33 +1,40 @@ -namespace service.Controllers +namespace service.Controllers { using System; - using System.Collections.Generic; - using System.Linq; using System.Net; using System.Threading.Tasks; - using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; - using Newtonsoft.Json; using Vtex.Api.Context; using WishList.Data; using WishList.Models; + using WishList.Services; public class RoutesController : Controller { private readonly IIOServiceContext _context; private readonly IWishListRepository _wishListRepository; + private readonly IWishListService _wishListService; - public RoutesController(IIOServiceContext context, IWishListRepository wishListRepository) + public RoutesController(IIOServiceContext context, IWishListRepository wishListRepository, IWishListService wishListService) { this._context = context ?? throw new ArgumentNullException(nameof(context)); this._wishListRepository = wishListRepository ?? throw new ArgumentNullException(nameof(wishListRepository)); + this._wishListService = wishListService ?? throw new ArgumentNullException(nameof(wishListService)); } public async Task ExportAllLists() { - WishListsWrapper wishListsWrapper = await _wishListRepository.GetAllLists(); - - return Json(wishListsWrapper); + HttpStatusCode isAdminUser = await _wishListService.IsValidAuthUser(); + if (isAdminUser.Equals(HttpStatusCode.OK)) + { + WishListsWrapper wishListsWrapper = await _wishListRepository.GetAllLists(); + + return Json(wishListsWrapper); + } + else + { + return Unauthorized(); + } } } } From 5179ac6318c8bd1905c49651a341a082dc419be2 Mon Sep 17 00:00:00 2001 From: Brian Talma <47258865+btalma@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:00:33 -0500 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6132b40..8b49984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added +- Added Admin validation for list export + ### Changed - Cypress code improvements