From f2ec20484e4d180f01bce998a44ab3c08e4075a2 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 9 Jan 2020 20:17:32 -0500 Subject: [PATCH] Provide the relevant RightsType in TgsAuthorizeAttributes --- .../Controllers/TgsAuthorizeAttribute.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Tgstation.Server.Host/Controllers/TgsAuthorizeAttribute.cs b/src/Tgstation.Server.Host/Controllers/TgsAuthorizeAttribute.cs index 0d52ac6ae1..4501a9783f 100644 --- a/src/Tgstation.Server.Host/Controllers/TgsAuthorizeAttribute.cs +++ b/src/Tgstation.Server.Host/Controllers/TgsAuthorizeAttribute.cs @@ -11,6 +11,11 @@ namespace Tgstation.Server.Host.Controllers [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] sealed class TgsAuthorizeAttribute : AuthorizeAttribute { + /// + /// Gets the associated with the if any. + /// + public RightsType? RightsType { get; } + /// /// Construct a /// @@ -23,6 +28,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(AdministrationRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.Administration; } /// @@ -32,6 +38,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(InstanceManagerRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.InstanceManager; } /// @@ -41,6 +48,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(RepositoryRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.Repository; } /// @@ -50,6 +58,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(ByondRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.Byond; } /// @@ -59,6 +68,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(DreamMakerRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.DreamMaker; } /// @@ -68,6 +78,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(DreamDaemonRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.DreamDaemon; } /// @@ -77,6 +88,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(ChatBotRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.ChatBots; } /// @@ -86,6 +98,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(ConfigurationRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.Configuration; } /// @@ -95,6 +108,7 @@ namespace Tgstation.Server.Host.Controllers public TgsAuthorizeAttribute(InstanceUserRights requiredRights) { Roles = RightsHelper.RoleNames(requiredRights); + RightsType = Api.Rights.RightsType.InstanceUser; } } }