<tyro-ui-auth-modal>
Auth Modal
Login modal, fully driven by
TyroUiAuthService. No @Input() - place the component once in the root layout. Demo
Open the login modal
Signals (read)
Member | Type | Description |
|---|---|---|
user() | Signal<ITyroUiUser | null> | Logged-in user - null if disconnected |
modalOpen() | Signal<boolean> | True while the modal is open |
modalTab() | Signal<'login' | 'register'> | Active tab inside the modal |
loading() | Signal<boolean> | True during the login API call |
error() | Signal<string | null> | Error message from the last attempt |
Methods
Member | Type | Description |
|---|---|---|
openModal() | void | Opens the login modal |
closeModal() | void | Closes the modal |
login(login, password) | Promise<void> | Submits login to the Useritium API |
logout() | void | Logs out and clears the session |
Setup
Root layout - add once
<tyro-ui-dashboard-layout [...]>
<router-outlet />
</tyro-ui-dashboard-layout>
<tyro-ui-auth-modal></tyro-ui-auth-modal>Usage in a component
readonly auth = inject(TyroUiAuthService);
// Ouvrir la modale
this.auth.openModal();
// Lire l'utilisateur (signal)
const user = this.auth.user(); // ITyroUiUser | null
// Déconnexion
this.auth.logout();