fix injectionses
This commit is contained in:
parent
b93115d787
commit
cd078ca643
11 changed files with 119 additions and 55 deletions
|
@ -4,5 +4,23 @@ namespace Femto.Api;
|
|||
|
||||
internal class CurrentUserContext : ICurrentUserContext
|
||||
{
|
||||
public CurrentUser? CurrentUser { get; set; }
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue