method Principal.userId
The id of the user; AccessDenied when the caller is not a user.
Example:
fn main() io {
let ann = Principal.User("ann", [], Map.new(), false, none)
print("{ann.userId()!}")
match Principal.Anonymous.userId() {
str id => print(id)
AccessDenied _ => print("not a user")
}
}Output
ann not a user
pub(api) fn userId() -> str | AccessDeniedSince. 1.0.0-beta
Returns
str
Errors
AccessDenied@error- `AccessDenied` when the caller is not a user.
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/rpc.oxl:188