Runlight.Accounts.Web (runlight v0.1.0)

Copy Markdown View Source

Accounts on the web: sign-in, the code step, invites, first-run setup, and the Account and People APIs, under the base path the routes answer at (the SDK's accounts/web.ts). Runlight.routes(rl, accounts: true) makes one.

Summary

Functions

What a signed-in person may do: everything (owner and admin), "member", "read" (viewer), or nothing.

The account a request comes from, or nil.

Answers an account page or API request at a path under the base, or nil for anything else.

Whether there is any account yet.

Accounts on the web. Options: runlight, secret (signs sessions and seals two-factor secrets; keep it stable across restarts), base, now, first_account (who may create the first account: {:code, code}, {:token, token}, :open, or :locked), home (a function answering the install's public address, or nil), and forgot (where the sign-in page sends someone who forgot their password).

A random one-time code, such as the one a server prints to unlock its first account.

The signed-in account for a request, or nil.

Notes who made a token. False when they can no longer make one (a viewer, or gone), which takes it back.

Types

t()

@type t() :: %Runlight.Accounts.Web{
  accounts: term(),
  base: term(),
  first: term(),
  forgot: term(),
  home: term(),
  id: term(),
  now: term(),
  rl: term(),
  throttles: term()
}

Functions

access(web, request)

@spec access(t(), Runlight.Http.Request.t()) :: true | false | String.t()

What a signed-in person may do: everything (owner and admin), "member", "read" (viewer), or nothing.

account_of(web, request)

The account a request comes from, or nil.

handle(web, request, path)

@spec handle(t(), Runlight.Http.Request.t(), String.t()) ::
  Runlight.Http.Response.t() | nil

Answers an account page or API request at a path under the base, or nil for anything else.

has_account(web)

Whether there is any account yet.

new(opts)

@spec new(keyword()) :: t()

Accounts on the web. Options: runlight, secret (signs sessions and seals two-factor secrets; keep it stable across restarts), base, now, first_account (who may create the first account: {:code, code}, {:token, token}, :open, or :locked), home (a function answering the install's public address, or nil), and forgot (where the sign-in page sends someone who forgot their password).

setup_code()

A random one-time code, such as the one a server prints to unlock its first account.

signed_in(web, request)

The signed-in account for a request, or nil.

token_made(web, token, by)

Notes who made a token. False when they can no longer make one (a viewer, or gone), which takes it back.