Temporarly disable authorization to help Deployment side

features/training-svc^2
Leo TUAILLON 4 days ago
parent f39101726f
commit 92dd362acb

@ -23,11 +23,11 @@ public class ExercicesController : ControllerBase
_mapper = mapper;
}
[Authorize]
//[Authorize]
[HttpPost]
public async Task<IActionResult> Create([FromBody] CreateExerciceTemplateDto dto)
{
if (User.Identity.Name != "admin") return Forbid();
//if (User.Identity.Name != "admin") return Forbid();
var exercice = _mapper.Map<Exercice>(dto);
_context.Exercices.Add(exercice);
@ -35,11 +35,11 @@ public class ExercicesController : ControllerBase
return CreatedAtAction(nameof(GetById), new { id = exercice.Id }, _mapper.Map<ExerciceTemplateDto>(exercice));
}
[Authorize]
//[Authorize]
[HttpPut("{id}")]
public async Task<IActionResult> Update(string id, [FromBody] UpdateExerciceTemplateDto dto)
{
if (User.Identity.Name != "admin") return Forbid();
//if (User.Identity.Name != "admin") return Forbid();
var exercice = await _context.Exercices.FindAsync(id);
if (exercice == null) return NotFound();
@ -50,11 +50,11 @@ public class ExercicesController : ControllerBase
return NoContent();
}
[Authorize]
//[Authorize]
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(string id)
{
if (User.Identity.Name != "admin") return Forbid();
//if (User.Identity.Name != "admin") return Forbid();
var exercice = await _context.Exercices.FindAsync(id);
if (exercice == null) return NotFound();
@ -64,17 +64,15 @@ public class ExercicesController : ControllerBase
return NoContent();
}
[Authorize]
//[Authorize]
[HttpGet("{id}")]
public async Task<ActionResult<ExerciceTemplateDto>> GetById(string id)
{
if (User.Identity.Name != "admin") return Forbid();
//if (User.Identity.Name != "admin") return Forbid();
var exercice = await _context.Exercices.FindAsync(id);
if (exercice == null) return NotFound();
return _mapper.Map<ExerciceTemplateDto>(exercice);
}
}
Loading…
Cancel
Save