19 lines
666 B
C#
19 lines
666 B
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using QuestionsApi.Services;
|
|
using System.Security.Claims;
|
|
|
|
namespace QuestionsApi.Controllers;
|
|
|
|
[ApiController, Route("api/progression"), Authorize(Roles = "USER,SUPER")]
|
|
public sealed class ProgressionController(ProgressionStore progression) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> Get()
|
|
{
|
|
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? User.FindFirstValue(ClaimTypes.Name)
|
|
?? User.Identity?.Name ?? "";
|
|
return string.IsNullOrWhiteSpace(userId) ? Unauthorized() : Ok(await progression.GetAsync(userId));
|
|
}
|
|
}
|