mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 08:33:19 +01:00
Fix when user sanity check happens in AuthenticationContext
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user