femto-backend/Femto.Api/CurrentUserContext.cs
2025-05-21 13:52:12 +02:00

26 lines
602 B
C#

using Femto.Common;
namespace Femto.Api;
internal class CurrentUserContext : ICurrentUserContext
{
private CurrentUser? _currentUser;
public CurrentUser? TryGetUserCurrentUser() => this._currentUser;
public bool HasUser => this._currentUser is not null;
public CurrentUser CurrentUser
{
get
{
if (_currentUser is null)
throw new InvalidOperationException(
"don't access current user if not authenticated"
);
return _currentUser;
}
set => _currentUser = value;
}
}