Fix some rights stuff

This commit is contained in:
Jordan Brown
2018-08-13 13:59:41 -04:00
parent 873ff66858
commit 30eca49e67
4 changed files with 5 additions and 5 deletions
@@ -59,6 +59,6 @@ namespace Tgstation.Server.Api.Models.Internal
/// The <see cref="Rights"/> required to cancel the <see cref="Job"/>
/// </summary>
[Permissions(DenyWrite = true)]
public int? CancelRight { get; set; }
public ulong? CancelRight { get; set; }
}
}
@@ -103,7 +103,7 @@ namespace Tgstation.Server.Host.Controllers
//if there's no instance user, do a weird thing and add all the instance roles
//we need it so we can get to OnActionExecutionAsync where we can properly decide between BadRequest and Forbid
//if user is null that means they got the token with an expired password
var rightInt = authenticationContext.User == null || (RightsHelper.IsInstanceRight(I) && authenticationContext.InstanceUser == null) ? ~0 : authenticationContext.GetRight(I);
var rightInt = authenticationContext.User == null || (RightsHelper.IsInstanceRight(I) && authenticationContext.InstanceUser == null) ? ~0U : authenticationContext.GetRight(I);
var rightEnum = RightsHelper.RightToType(I);
var right = (Enum)Enum.ToObject(rightEnum, rightInt);
foreach (Enum J in Enum.GetValues(rightEnum))
@@ -59,7 +59,7 @@ namespace Tgstation.Server.Host.Security
public IAuthenticationContext Clone() => new AuthenticationContext(SystemIdentity.Clone(), User, InstanceUser);
/// <inheritdoc />
public int GetRight(RightsType rightsType)
public ulong GetRight(RightsType rightsType)
{
var isInstance = RightsHelper.IsInstanceRight(rightsType);
@@ -81,7 +81,7 @@ namespace Tgstation.Server.Host.Security
if (right == null)
throw new InvalidOperationException("A user right was null!");
return (int)right;
return (ulong)right;
}
}
}
@@ -24,7 +24,7 @@ namespace Tgstation.Server.Host.Security
/// </summary>
/// <param name="rightsType">The <see cref="RightsType"/> of the right to get</param>
/// <returns>The value of <paramref name="rightsType"/>. Note that if <see cref="InstanceUser"/> is <see langword="null"/> all <see cref="Instance"/> based rights will return 0</returns>
int GetRight(RightsType rightsType);
ulong GetRight(RightsType rightsType);
/// <summary>
/// The <see cref="ISystemIdentity"/> of <see cref="User"/> if applicable