method Principal.scoped
The same user with only the roles also listed in keep (for asScoped); other principals are unchanged.
Example:
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>) -> PrincipalComplexity. O(roles).
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
keep | List<str> |
Returns
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/rpc.oxl:210