Skip to content

Commit

Permalink
[*] ProductsController : restricted access to Create, Edit, Delete me…
Browse files Browse the repository at this point in the history
…thods for non-admin users
  • Loading branch information
svasorcery committed Apr 16, 2018
1 parent 1837fb3 commit 2d71f49
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion LegendaryStore/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace LegendaryStore.Controllers
using LegendaryStore.Models;
using LegendaryStore.Services;

[Authorize]
[Route("api/[controller]")]
public class ProductsController : Controller
{
Expand Down Expand Up @@ -52,6 +51,7 @@ public async Task<IActionResult> ByCategory([FromRoute]int categoryId, int page
return Ok(result);
}

[Authorize(Policy = "FullAccess")]
[HttpGet("{id:int}")]
public async Task<IActionResult> Get([FromRoute]int id)
{
Expand All @@ -73,6 +73,7 @@ public async Task<IActionResult> Get([FromRoute]int id)
return Ok(model);
}

[Authorize(Policy = "FullAccess")]
[HttpPost]
public async Task<IActionResult> Create([FromBody]Product model)
{
Expand All @@ -89,6 +90,7 @@ public async Task<IActionResult> Create([FromBody]Product model)
}
}

[Authorize(Policy = "FullAccess")]
[HttpPut("{id:int}")]
public async Task<IActionResult> Edit([FromRoute]int id, [FromBody]Product model)
{
Expand All @@ -104,6 +106,7 @@ public async Task<IActionResult> Edit([FromRoute]int id, [FromBody]Product model
}
}

[Authorize(Policy = "FullAccess")]
[HttpDelete("{id:int}")]
public async Task<IActionResult> Delete([FromRoute]int id)
{
Expand Down

0 comments on commit 2d71f49

Please sign in to comment.