Skip to content

@Guard rejects valid Players when clientID is 0 #61

@dnocturne

Description

@dnocturne

The @Guard wrapper validates the player context with a truthy check on player.clientID. RageMP assigns id: 0 to the very first player who connects, and that flows through into clientID. Because 0 is falsy in JavaScript, the wrapper mistakes a real Player for an invalid context and throws before authorization runs.

Steps to reproduce

  1. Define any guarded command:

    @Command('test')
    @Guard({ rank: 1 })
    testCommand(player: Player) {
      player.send('ok')
    }
  2. Start a fresh RageMP server

  3. Join as the first player. Your clientID is 0

  4. Run /test

Expected

The guard checks the player's principal/rank like any other player.

Actual

The wrapper throws before authorization runs:

Guard Security Error: Context is not a player

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions