method Principal.has
caller.has(role: .Support) (§13.2, D-5011): the caller is a user who has that role. R is the application's role enum
(roles from claim("roles") as AppRole): the compiler types the argument as that enum, the runtime compares variant names.
Example:
// needs `cluster app { auth { ...; roles from claim("roles") as AppRole } }` for the role type
enum AppRole { Support, Admin }
fn canRefund(caller: Principal) -> bool {
caller.has(role: .Support)
}pub(api) fn has<R: Show>(role: R) -> boolСложность. O(roles).
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
role | R |
Возвращает
bool
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/rpc.oxl:103