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;
    }
}
