AdminManager can now load permissions for registered callback commands. (#6025)

This commit is contained in:
Vera Aguilera Puerto
2022-01-12 11:05:39 +01:00
committed by GitHub
parent 414225f463
commit c4bf0a9479
6 changed files with 123 additions and 106 deletions

View File

@@ -12,7 +12,7 @@ namespace Content.Server.Administration
/// If this attribute is used multiple times, either attribute's flag sets can be used to get access.
/// </remarks>
/// <seealso cref="AnyCommandAttribute"/>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
[BaseTypeRequired(typeof(IConsoleCommand))]
[MeansImplicitUse]
public sealed class AdminCommandAttribute : Attribute

View File

@@ -436,7 +436,13 @@ namespace Content.Server.Administration.Managers
private static (bool isAvail, AdminFlags[] flagsReq) GetRequiredFlag(IConsoleCommand cmd)
{
var type = cmd.GetType();
MemberInfo type = cmd.GetType();
if (cmd is ConsoleHost.RegisteredCommand registered)
{
type = registered.Callback.Method;
}
if (Attribute.IsDefined(type, typeof(AnyCommandAttribute)))
{
// Available to everybody.