OxL Reference

method Principal.scoped

The same user with only the roles also listed in keep (for asScoped); other principals are unchanged.

Example:

oxl✓ checked in CI
fn main() io {
  let ann = Principal.User("ann", ["Admin", "Support"], Map.new(), false, none)
  let narrow = ann.scoped(["Support"])
  print("{narrow.hasRole("Admin")} {narrow.hasRole("Support")}")
}
Output
false true
pub(api) fn scoped(keep: List<str>) -> Principal

Complexity. O(roles).

Since. 1.0.0-beta

Parameters

NameType
keepList<str>

Returns

Principal

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/rpc.oxl:210

See also