Back to Consul

AuthDialog

ui/packages/consul-ui/app/components/auth-dialog/README.mdx

1.22.71.3 KB
Original Source

AuthDialog

A component to help orchestrate a login/logout flow.

hbs
<AuthDialog
  @src={{uri 'settings://consul:token'}}
  @sink={{uri 'settings://consul:token'}}
  @onchange={{action (noop)}}
>
  <:unauthorized as |api|>
    <AuthForm
      @onsubmit={{action api.login value="data"}}
    />
  </:unauthorized>
  <:authorized as |api|>
    <button
      {{on 'click' (fn api.logout)}}
    >
      Logout
    </button>
  </:authorized>
</AuthDialog>

Arguments

ArgumentTypeDefaultDescription
onchangeFunctionAn action to fire when the users token has changed (logged in/logged out/token changed)
srcURIDataSource URI used to retrive/watch for changes on the users token
sinkURIDataSink URI used to save the users token to

Exports

NameTypeDescription
loginFunctionLogin with a specified token
logoutFunctionLogout (delete token)
tokenTokenThe current token itself

Slots

NameDescription
unauthorizedThis slot is only rendered when the user doesn't have a token
authorizedThis slot is only rendered when the user has a token.

See