using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using QuestionsApi.Services; using System.Security.Claims; namespace QuestionsApi.Controllers; [ApiController] [Route("api/[controller]")] public class RatingsController : ControllerBase { private readonly RatingStore _ratings; public RatingsController(RatingStore ratings) { _ratings = ratings; } [HttpGet("me")] [Authorize(Roles = "USER,SUPER")] public async Task Me() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? User.FindFirstValue(ClaimTypes.Name) ?? User.Identity?.Name ?? ""; if (string.IsNullOrWhiteSpace(userId)) return Unauthorized(); return Ok(await _ratings.GetProfileAsync(userId)); } }