using LocationsApi.Models; using LocationsApi.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; namespace LocationsApi.Controllers; [ApiController] [Route("api/[controller]")] public class ResourcesController : ControllerBase { private readonly ResourceService _resources; public ResourcesController(ResourceService resources) { _resources = resources; } [Authorize(Roles = "USER,SUPER")] [HttpGet("me")] public async Task> GetMine() { var username = User.FindFirstValue(ClaimTypes.Name); if (string.IsNullOrWhiteSpace(username)) { return Unauthorized(); } var resources = await _resources.GetAsync(username); return Ok(PlayerResourcesResponse.FromResources(resources)); } }