forked from MDCPS/DamageAssessment_Backend
implementation of Authentication using JWT. Security applied on all microservices endpoints.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using DamageAssesment.Api.Surveys.Interfaces;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DamageAssesment.Api.Surveys.Controllers
|
||||
@ -15,7 +16,7 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
/// <summary>
|
||||
/// GET request for retrieving surveys.
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles ="admin,survey,user,report")]
|
||||
[Route("Surveys")]
|
||||
[Route("Surveys/{language:alpha}")]
|
||||
[HttpGet]
|
||||
@ -32,6 +33,7 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
/// <summary>
|
||||
/// GET request for retrieving surveys by ID.
|
||||
/// </summary>
|
||||
[Authorize(Roles = "admin,survey,user,report")]
|
||||
[Route("Surveys/{id:int}")]
|
||||
[Route("Surveys/{id:int}/{language:alpha}")]
|
||||
[HttpGet]
|
||||
@ -47,7 +49,7 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
/// <summary>
|
||||
/// POST request for creating a new survey.
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles = "admin,survey,user,report")]
|
||||
[HttpPost("Surveys")]
|
||||
public async Task<ActionResult> PostSurveysAsync(Models.Survey survey)
|
||||
{
|
||||
@ -62,7 +64,7 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
/// PUT request for updating an existing survey (surveyId,Updated Survey data).
|
||||
/// </summary>
|
||||
|
||||
|
||||
[Authorize(Roles = "admin,survey")]
|
||||
[HttpPut("Surveys/{id}")]
|
||||
public async Task<ActionResult> PutSurveysAsync(int id, Models.Survey survey)
|
||||
{
|
||||
@ -80,6 +82,7 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
||||
/// <summary>
|
||||
/// DELETE request for deleting a survey by ID.
|
||||
/// </summary>
|
||||
[Authorize(Roles = "admin,survey")]
|
||||
[HttpDelete("Surveys/{id}")]
|
||||
public async Task<ActionResult> DeleteSurveysAsync(int id)
|
||||
{
|
||||
|
Reference in New Issue
Block a user