2021-03-17 15:58:17 +00:00
|
|
|
# AuthDialog
|
2020-05-11 15:37:11 +00:00
|
|
|
|
2022-01-07 19:08:25 +00:00
|
|
|
A component to help orchestrate a login/logout flow.
|
|
|
|
|
2021-03-17 15:58:17 +00:00
|
|
|
```hbs preview-template
|
2021-11-24 14:53:12 +00:00
|
|
|
<AuthDialog
|
2022-01-07 19:08:25 +00:00
|
|
|
@src={{uri 'settings://consul:token'}}
|
|
|
|
@sink={{uri 'settings://consul:token'}}
|
2021-11-24 14:53:12 +00:00
|
|
|
@onchange={{action (noop)}}
|
2022-01-07 19:08:25 +00:00
|
|
|
>
|
|
|
|
<:unauthorized as |api|>
|
|
|
|
<AuthForm
|
|
|
|
@onsubmit={{action api.login value="data"}}
|
|
|
|
/>
|
|
|
|
</:unauthorized>
|
|
|
|
<:authorized as |api|>
|
|
|
|
<button
|
|
|
|
{{on 'click' (fn api.logout)}}
|
|
|
|
>
|
|
|
|
Logout
|
|
|
|
</button>
|
|
|
|
</:authorized>
|
2020-05-11 15:37:11 +00:00
|
|
|
</AuthDialog>
|
|
|
|
```
|
|
|
|
|
2022-01-07 19:08:25 +00:00
|
|
|
## Arguments
|
2020-05-11 15:37:11 +00:00
|
|
|
|
|
|
|
| Argument | Type | Default | Description |
|
|
|
|
| --- | --- | --- | --- |
|
|
|
|
| `onchange` | `Function` | | An action to fire when the users token has changed (logged in/logged out/token changed) |
|
2022-01-07 19:08:25 +00:00
|
|
|
| `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 |
|
2020-05-11 15:37:11 +00:00
|
|
|
|
2022-01-07 19:08:25 +00:00
|
|
|
## Exports
|
2020-05-11 15:37:11 +00:00
|
|
|
|
2022-01-07 19:08:25 +00:00
|
|
|
| Name | Type | Description |
|
|
|
|
| --- | --- | --- |
|
|
|
|
| `login` | `Function` | Login with a specified token |
|
|
|
|
| `logout` | `Function` | Logout (delete token) |
|
|
|
|
| `token` | `Token` | The current token itself |
|
2020-05-11 15:37:11 +00:00
|
|
|
|
2022-01-07 19:08:25 +00:00
|
|
|
## Slots
|
2020-05-11 15:37:11 +00:00
|
|
|
|
|
|
|
| Name | Description |
|
|
|
|
| --- | --- |
|
|
|
|
| `unauthorized` | This slot is only rendered when the user doesn't have a token |
|
2022-01-07 19:08:25 +00:00
|
|
|
| `authorized` | This slot is only rendered when the user has a token.|
|
2020-05-11 15:37:11 +00:00
|
|
|
|
2022-01-07 19:08:25 +00:00
|
|
|
## See
|
2020-05-11 15:37:11 +00:00
|
|
|
|
|
|
|
- [Component Source Code](./index.js)
|
|
|
|
- [Template Source Code](./index.hbs)
|
|
|
|
|
|
|
|
---
|