OxL Справочник OxL
РусскийEnglish

method Ctx.userId

The id of the calling user; AccessDenied when the caller is not a user (ctx.caller.userId(), §13.2).

Example:

oxl✓ проверяется в CI
service Whoami {
  @public rpc me() -> str
}

impl Whoami {
  rpc me() {
    match ctx.userId() {
      str id => id
      AccessDenied _ => "anonymous"
    }
  }
}

fn main() io, net {
  print("{Whoami.me()!}")
}
Вывод
anonymous
pub(api) fn userId() -> str | AccessDenied

С версии. 1.0.0-beta

Возвращает

str

Ошибки

  • AccessDenied @error
  • `AccessDenied` when the caller is not a user.

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/core/rpc.oxl:293

См. также