diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index 83948ce8b6..b27902d9d0 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -11,15 +11,7 @@ namespace Tgstation.Server.Host.Security sealed class AuthenticationContext : IAuthenticationContext { /// - public User User - { - get - { - if (user == null) - throw new InvalidOperationException("AuthenticationContext has no user!"); - return user; - } - } + public User User { get; private set; } /// public InstanceUser InstanceUser { get; } @@ -27,11 +19,6 @@ namespace Tgstation.Server.Host.Security /// public ISystemIdentity SystemIdentity { get; } - /// - /// Backing field for - /// - readonly User user; - /// /// Construct an empty /// @@ -45,7 +32,7 @@ namespace Tgstation.Server.Host.Security /// The value of public AuthenticationContext(ISystemIdentity systemIdentity, User user, InstanceUser instanceUser) { - this.user = user ?? throw new ArgumentNullException(nameof(user)); + User = user ?? throw new ArgumentNullException(nameof(user)); if (systemIdentity == null && User.SystemIdentifier != null) throw new ArgumentNullException(nameof(systemIdentity)); InstanceUser = instanceUser; @@ -60,8 +47,8 @@ namespace Tgstation.Server.Host.Security { var isInstance = RightsHelper.IsInstanceRight(rightsType); - //forces the null user check - var pullThis = User; + if (User == null) + throw new InvalidOperationException("Authentication context has no user!"); if (isInstance && InstanceUser == null) return 0;