mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
6bdb2c2216
- Move AuthDialog to use a Glimmer Component plus native named blocks/slots. - Unravel the Auth* contextual components, there wasn't a lot of point having them as contextual components and now the AuthDialog (non-view-specific state machine component) can be used entirely separately from the view-specific components (AuthForm and AuthProfile). - Move all the ACL related components that are in the main app chrome/navigation (our HashicorpConsul component) in our consul-acls sub package/module (which will eventually be loaded on demand only when ACLs are enabled)
58 lines
1.4 KiB
Plaintext
58 lines
1.4 KiB
Plaintext
# AuthDialog
|
|
|
|
A component to help orchestrate a login/logout flow.
|
|
|
|
```hbs preview-template
|
|
<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|>
|
|
<AuthProfile
|
|
@item={{api.token}}
|
|
/>
|
|
<button
|
|
{{on 'click' (fn api.logout)}}
|
|
>
|
|
Logout
|
|
</button>
|
|
</:authorized>
|
|
</AuthDialog>
|
|
```
|
|
|
|
## Arguments
|
|
|
|
| Argument | Type | Default | Description |
|
|
| --- | --- | --- | --- |
|
|
| `onchange` | `Function` | | An action to fire when the users token has changed (logged in/logged out/token changed) |
|
|
| `src` | `URI` | | DataSource URI used to retrive/watch for changes on the users token |
|
|
| `sink` | `URI` | | DataSink URI used to save the users token to |
|
|
|
|
## Exports
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `login` | `Function` | Login with a specified token |
|
|
| `logout` | `Function` | Logout (delete token) |
|
|
| `token` | `Token` | The current token itself |
|
|
|
|
## Slots
|
|
|
|
| Name | Description |
|
|
| --- | --- |
|
|
| `unauthorized` | This slot is only rendered when the user doesn't have a token |
|
|
| `authorized` | This slot is only rendered when the user has a token.|
|
|
|
|
## See
|
|
|
|
- [Component Source Code](./index.js)
|
|
- [Template Source Code](./index.hbs)
|
|
|
|
---
|