Table of Contents

Class ModerationGuards

Namespace
FishMMO.ControlPanel.Controllers
Assembly
FishMMO-ControlPanel.dll

The rules every moderation action shares about who may act on whom.

public static class ModerationGuards
Inheritance
ModerationGuards
Inherited Members

Remarks

Gathered in one place because they are the part that is easy to get subtly wrong and easy to forget on the fifth endpoint. Each one closes a route from "administering" to "escalating":

  • Not yourself. An operator banning or demoting their own account is either a mistake or an attempt to look like they were not present.
  • Not a peer or a superior. The damaging case is not two game masters kicking each other in a loop; it is a compromised game master account removing the administrators who would notice.
  • Not granting at or above your own level. Without this an administrator can mint administrators, which makes every ceiling above decorative.

These are checked against the level the panel read from the database on this very request, not from anything the client sent.

Methods

ActorLevel(ControllerBase)

The signed-in operator's access level.

public static AccessLevel ActorLevel(ControllerBase controller)

Parameters

controller ControllerBase

Returns

AccessLevel

Check(ControllerBase, string, AccessLevel)

Refuses an action against the operator's own account, or against a peer or superior.

public static IActionResult Check(ControllerBase controller, string targetAccount, AccessLevel targetLevel)

Parameters

controller ControllerBase
targetAccount string
targetLevel AccessLevel

Returns

IActionResult

An error result to return, or null when the action may proceed.

CheckGrant(ControllerBase, AccessLevel)

Refuses granting a level at or above the operator's own.

public static IActionResult CheckGrant(ControllerBase controller, AccessLevel granted)

Parameters

controller ControllerBase
granted AccessLevel

Returns

IActionResult

An error result to return, or null when the grant may proceed.