using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using QuestionsApi.Services; using System.Security.Claims; namespace QuestionsApi.Controllers; [ApiController] [Route("api/dashboard")] [Authorize(Roles = "USER,SUPER")] public sealed class DashboardController(DashboardStore dashboard, ProgressionStore progression) : ControllerBase { [HttpGet] public async Task Get() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? User.FindFirstValue(ClaimTypes.Name) ?? User.Identity?.Name ?? ""; if (string.IsNullOrWhiteSpace(userId)) return Unauthorized(); var response = await dashboard.GetAsync(userId, DateTime.UtcNow); response.Progression = await progression.GetAsync(userId); return Ok(response); } }