diff --git a/api/src/Controllers/UsersController.cs b/api/src/Controllers/UsersController.cs index 4491636..195741e 100644 --- a/api/src/Controllers/UsersController.cs +++ b/api/src/Controllers/UsersController.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; +using System.Security.Claims; +using Microsoft.AspNetCore.Identity; using agologumApi.Models; using agologumApi.Services; @@ -64,12 +66,13 @@ public class UsersController : ControllerBase { [HttpDelete("{id}")] public async Task deleteUser(string id) { + var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); + if(userId == id) return BadRequest(); // dont allow deletion of yourself + var success = await service_.Delete(id); if (!success) return NotFound(); - // TODO: set safeguard to no delete the current user - return NoContent(); }