Skip to content

Commit

Permalink
docs: added migration section about new logout event [skip test]
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Feb 3, 2025
1 parent def30d5 commit da804f5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/api/core/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ Events.on('myGlobal-changed', myCallback) // When updating a root object
Events.on('myGlobal-property-changed', myCallback) // When updating a specific property path
```

### Guards

[Navigation guards](https://router.vuejs.org/guide/advanced/navigation-guards.html) control access to [routes](https://quasar.dev/layout/routing-with-layouts-and-pages/) within an application. They allow you to define navigation rules in your app based on the user's status (authenticated or not), permissions, and route definitions.

The **KDK** provides you with some built-in before guards and a mecanism to register your own ones, more details can be found in our [application template](https://kalisio.github.io/skeleton/guides/howtos/guards.html).

### Storage

The **Storage** singleton provides you with high level functions to upload and download files using the [Storage service](./services.md#storage-service).
Expand Down
10 changes: 10 additions & 0 deletions docs/api/core/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ The composable exposes the following:
* **has(path)**: test if a store has a value by path
* **forOwn(f)**: call function `f` on each `(value, key)` of the store

## useSession

Used to manage user client session with the following options:
* **redirect** function to override default redirection behaviour with the following arguments:
* `route` current route,
* `result` from before guard,
* `user` current user (null if none currently authentified).

Rely on [global guards](./application.md#guards) to ensure redirection. It also manages the socket connection state and will display disconnection/reconnection dialogs accordingly.

## useContext

Used to manage the current context of the application, call **useContext()** with the following arguments:
Expand Down
32 changes: 31 additions & 1 deletion docs/guides/migration/v2.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,34 @@ authentication: {
...
}
```
:::
:::

👉 New `logout` custom method and related custom event that can be sent from server to connected clients whenever a user has logout from one client of your application.

::: details ⬇️ How you can call it to logout all clients
```js
// channels.js of your application
app.on('logout', (authResult, { connection }) => {
// connection can be undefined if there is no
// real-time connection, e.g. when logging in via REST
if (connection) {
// Obtain the logged user from the connection
const user = connection.user
const usersService = app.getService('users')
usersService.logout(user)
}
})
const usersService = app.getService('users')
usersService.publish('logout', (data, hook) => {
const user = data
// Publish logout event to target user only
return app.channel('authenticated').filter(connection => {
const connectionUser = connection.user
return user && connectionUser && connectionUser._id.toString() === user._id.toString()
})
})
```

On the client side the [session composable](../../api/core/composables#usesession) will listen to this event automatically to redirect the user to the logout page.
```
:::

0 comments on commit da804f5

Please sign in to comment.