CounterStrikeSharp icon indicating copy to clipboard operation
CounterStrikeSharp copied to clipboard

[BUG] @domain/root flag does not work with RequiresPermissionsOr annotation

Open rothadamcz opened this issue 1 year ago • 4 comments

When admin has @domain/root flag, it is ignored when using RequiresPermissionsOr annotation.

Example

  • Admin has only 1 flag (@css/root)
  • He is not able to execute css_ban (command implementation bellow), because he does not have @css/ban nor @something/else flag.
public override void Load(bool hotReload)
{
    AddCommand("css_ban", "Ban a player", OnCommand);
}

[RequiresPermissionsOr("@css/ban", "@something/else")]
[CommandHelper(minArgs: 1, usage: "[id]", whoCanExecute: CommandUsage.CLIENT_ONLY)]
public static void OnCommand(CCSPlayerController? caller, CommandInfo info)
{
    if (caller == null) return;

    info.ReplyToCommand("Hello World!");
}

Confirmed on API version: v291 (1.0.291+6349c11)

rothadamcz avatar Dec 02 '24 20:12 rothadamcz

To clarify, I think the intended behavior should be that access to the command should be granted, because required permission is @css/ban OR @something/else and since admin has @css/root which enables all @css flags including @css/ban, the requirement is met.

rothadamcz avatar Dec 03 '24 11:12 rothadamcz

Kia ora! I've been able to replicate the bug in the test suite, and I've found the cause of the issue in the code (which I wrote ages ago).

zonical avatar Dec 03 '24 20:12 zonical

Any news about fix @zonical?

crashzk avatar Jan 22 '25 00:01 crashzk

Any news about fix @zonical?

Hi! Sorry for the lack of work on this. I've been busy with work. I'll re-look into this in a few days.

zonical avatar Jan 23 '25 20:01 zonical