using GameAuthApi.Models; using GameAuthApi.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; namespace GameAuthApi.Controllers; [ApiController] [Route("api/[controller]")] public class UserController : ControllerBase { private readonly UserService _userService; public UserController(UserService userService) { _userService = userService; } // GET: /api/User [HttpGet] [Authorize(Roles = "SUPER")] public async Task GetAllUsers() { var users = await _userService.GetAllAsync(); return Ok(users); } // DELETE: /api/User?username=foo [HttpDelete] [Authorize(Roles = "SUPER")] public async Task DeleteUser([FromQuery] string username) { var deleted = await _userService.DeleteAsync(username); if (!deleted) return NotFound($"User '{username}' not found."); return Ok($"User '{username}' deleted successfully."); } }