Add missing right for custom BYOND versions [ApiDeploy][NugetDeploy]

This commit is contained in:
Jordan Brown
2020-07-09 15:54:25 -04:00
parent 0afcd8de4a
commit 91b665b239
3 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<TgsCoreVersion>4.4.0</TgsCoreVersion>
<TgsConfigVersion>2.0.0</TgsConfigVersion>
<TgsApiVersion>7.0.0</TgsApiVersion>
<TgsClientVersion>7.3.0</TgsClientVersion>
<TgsClientVersion>8.0.0</TgsClientVersion>
<TgsDmapiVersion>5.2.2</TgsDmapiVersion>
<TgsControlPanelVersion>0.4.0</TgsControlPanelVersion>
<TgsHostWatchdogVersion>1.1.0</TgsHostWatchdogVersion>
@@ -24,13 +24,18 @@ namespace Tgstation.Server.Api.Rights
ListInstalled = 2,
/// <summary>
/// User may change the active BYOND version
/// User may change the active BYOND version. Also allows installing official BYOND versions
/// </summary>
ChangeVersion = 4,
InstallOfficialOrChangeActiveVersion = 4,
/// <summary>
/// User may cancel version installations
/// </summary>
CancelInstall = 8
CancelInstall = 8,
/// <summary>
/// User may upload custom BYOND versions
/// </summary>
InstallCustomVersion = 16,
}
}
@@ -98,7 +98,7 @@ namespace Tgstation.Server.Host.Controllers
/// <response code="200">Switched active version successfully.</response>
/// <response code="202">Created <see cref="Api.Models.Job"/> to install and switch active version successfully.</response>
[HttpPost]
[TgsAuthorize(ByondRights.ChangeVersion)]
[TgsAuthorize(ByondRights.InstallOfficialOrChangeActiveVersion | ByondRights.InstallCustomVersion)]
[ProducesResponseType(typeof(Api.Models.Byond), 200)]
[ProducesResponseType(typeof(Api.Models.Byond), 202)]
public async Task<IActionResult> Update([FromBody] Api.Models.Byond model, CancellationToken cancellationToken)
@@ -111,6 +111,11 @@ namespace Tgstation.Server.Host.Controllers
|| (model.Content != null && model.Version.Build > 0))
return BadRequest(new ErrorMessage(ErrorCode.ModelValidationFailure));
var userByondRights = AuthenticationContext.InstanceUser.ByondRights.Value;
if ((!userByondRights.HasFlag(ByondRights.InstallOfficialOrChangeActiveVersion) && model.Content == null)
|| (!userByondRights.HasFlag(ByondRights.InstallCustomVersion) && model.Content != null))
return Forbid();
var byondManager = instanceManager.GetInstance(Instance).ByondManager;
// remove cruff fields