Sign-In and Sign-Out Events
An extension often keeps something for the signed-in user, such as a basket it merges when they sign in or clears when they leave. The module calls two Nuxt runtime hooks for this. A site can listen to them too.
Listening From a Plugin
// cwa-shop/runtime/plugin.client.ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('cwa:auth:signed-in', async ({ user }) => { await mergeGuestBasket(user['@id'])
})
nuxtApp.hook('cwa:auth:signed-out', () => { clearBasket()
})
})
Both hooks are typed, so user is the CWA user that /me returned.
When Each Is Called
| Hook | Called | Not called |
|---|---|---|
cwa:auth:signed-in | After a sign-in through $cwa.auth.signIn() (the login page and useLogin use it), once the user has loaded from /me | When a page loads for someone already signed in, or when the sign-in or the user's load fails |
cwa:auth:signed-out | Once, when a signed-in session ends in the browser: signing out, or a /me that fails because the session expired | During a server render, and for a visitor who was never signed in |
A session that's found to have expired during a server render loads the page signed out without calling cwa:auth:signed-out. To find out who's signed in when a page loads, read Authentication › Reading Auth State instead.
console.error. Handle your own errors if the user needs to know.Next: back to the Extending the CWA overview.
Admin Pages
Adding an extension's pages under /_cwa with a role and a menu entry, and building a list and an item dialog from the admin's own parts.
Deploying a CWA Site
Choose between one server with Docker Compose (a preview) and Kubernetes with Helm, then take a new site to production on Kubernetes step by step, with the template's GitLab or GitHub pipeline.