forked from xiongyuxing/tiku-backend.net
25 lines
729 B
C#
25 lines
729 B
C#
namespace Tiku.Application.Auth;
|
|
|
|
public interface IRequestSecurityState
|
|
{
|
|
AuthSessionValidationResult? ValidatedSession { get; }
|
|
|
|
void SetValidatedSession(AuthSessionValidationResult session);
|
|
}
|
|
|
|
internal sealed class RequestSecurityState : IRequestSecurityState
|
|
{
|
|
public AuthSessionValidationResult? ValidatedSession { get; private set; }
|
|
|
|
public void SetValidatedSession(AuthSessionValidationResult session)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(session);
|
|
if (ValidatedSession is not null && ValidatedSession != session)
|
|
{
|
|
throw new InvalidOperationException("The request security session was already initialized.");
|
|
}
|
|
|
|
ValidatedSession = session;
|
|
}
|
|
}
|