Fix when user sanity check happens in AuthenticationContext

This commit is contained in:
Jordan Brown
2018-10-11 00:15:32 -04:00
parent 17add23cb8
commit f9af6a180b
@@ -11,15 +11,7 @@ namespace Tgstation.Server.Host.Security
sealed class AuthenticationContext : IAuthenticationContext
{
/// <inheritdoc />
public User User
{
get
{
if (user == null)
throw new InvalidOperationException("AuthenticationContext has no user!");
return user;
}
}
public User User { get; private set; }
/// <inheritdoc />
public InstanceUser InstanceUser { get; }
@@ -27,11 +19,6 @@ namespace Tgstation.Server.Host.Security
/// <inheritdoc />
public ISystemIdentity SystemIdentity { get; }
/// <summary>
/// Backing field for <see cref="User"/>
/// </summary>
readonly User user;
/// <summary>
/// Construct an empty <see cref="AuthenticationContext"/>
/// </summary>
@@ -45,7 +32,7 @@ namespace Tgstation.Server.Host.Security
/// <param name="instanceUser">The value of <see cref="InstanceUser"/></param>
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;