Progress Overhaul + Profile Page and a LOT more! (#4262)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joe Milazzo
2025-12-09 10:00:11 -07:00
committed by GitHub
parent 4ac13f1f25
commit 9f29fa593d
645 changed files with 25585 additions and 4805 deletions
+21 -4
View File
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Authorization;
using API.Services.Store;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace API.Controllers;
@@ -10,8 +12,23 @@ namespace API.Controllers;
[Authorize]
public class BaseApiController : ControllerBase
{
public BaseApiController()
{
private IUserContext? _userContext;
}
/// <summary>
/// Gets the current user context. Available in all derived controllers.
/// </summary>
protected IUserContext UserContext =>
_userContext ??= HttpContext.RequestServices.GetRequiredService<IUserContext>();
/// <summary>
/// Gets the current authenticated user's ID.
/// Throws if user is not authenticated.
/// </summary>
protected int UserId => UserContext.GetUserIdOrThrow();
/// <summary>
/// Gets the current authenticated user's username.
/// </summary>
/// <remarks>Warning! Username's can contain .. and /, do not use folders or filenames explicitly with the Username</remarks>
protected string? Username => UserContext.GetUsername();
}