Added basic auth checking code. First bit of code to protect an API call in the Employee controller.
This commit is contained in:
@@ -25,13 +25,19 @@ namespace SecureCore.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Get()
|
||||
{
|
||||
return Ok(DataService.Get());
|
||||
if (Authentication.IsAllowed(HttpContext))
|
||||
return Ok(DataService.Get());
|
||||
else
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
[HttpGet("{id}", Name = "Get")]
|
||||
public IActionResult Get(int id)
|
||||
{
|
||||
return Ok(DataService.GetById(id));
|
||||
if (Authentication.IsAllowed(HttpContext))
|
||||
return Ok(DataService.GetById(id));
|
||||
else
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user