$auth
Middleware
The $auth
middleware is designed to protect pages that require a user to be authenticated. When applied to a route, it checks whether the user is currently logged in. If the user is not authenticated, they will be redirected to a specified login page or another route defined in your application.
Usage Example
To use the $auth
middleware, simply add it to the middleware
property of a page component or define it in the route configuration:
javascript
definePageMeta({
middleware: ['$auth'],
});
This ensures that only authenticated users can access the page. If an unauthenticated user tries to access a page guarded by $auth
, they will be redirected according to the logic defined in your application (typically to the login page).