Feature/Auth: last one was authentication, this one is authorization #4

Merged
homeburger merged 33 commits from feature/auth into main 2026-04-23 00:18:39 -05:00
Showing only changes of commit 68685e6398 - Show all commits

View File

@@ -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<ActionResult> 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();
}