Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security patch #150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 16 additions & 9 deletions dotnet/Controlers/RoutesController.cs
Original file line number Diff line number Diff line change
@@ -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<IActionResult> 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();
}
}
}
}