26 lines
602 B
C#
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;
|
|
}
|
|
}
|