Skip to content

Commit a10e857

Browse files
author
sideborg
committed
🔄 synced local 'content/2.nuxt-auth/' with remote 'docs/content/'
1 parent a82cf37 commit a10e857

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

content/2.nuxt-auth/3.application-side/4.protecting-pages.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Protecting Pages
22

33
`nuxt-auth` offers different approaches to protect pages:
4+
45
1. Global protection: Protects all pages with manual exceptions
56
2. Local protection: Protects specific pages
67
3. Custom middleware: Create your own middleware
@@ -48,6 +49,7 @@ That's it! Every page of your application will now need authentication for the u
4849
### Disabling the global middleware locally
4950

5051
To disable the global middleware on a specific page only, you can use the [`definePageMeta` macro](https://nuxt.com/docs/api/utils/define-page-meta#definepagemeta) to turn `auth` off:
52+
5153
```vue
5254
<!-- file: ~/pages/index.vue -->
5355
<template>
@@ -61,7 +63,6 @@ definePageMeta({ auth: false })
6163

6264
Note: This only works on `pages/`. It notably does not work inside the `app.vue`.
6365

64-
6566
## Local middleware
6667

6768
To protect specific pages with a middleware, you can use the [`definePageMeta` macro](https://nuxt.com/docs/api/utils/define-page-meta#definepagemeta) to turn `auth` on:

content/2.nuxt-auth/v0.6/3.application-side/4.protecting-pages.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ export default defineNuxtConfig({
4646

4747
That's it! Every page of your application will now need authentication for the user to visit it.
4848

49+
### Middleware Options
50+
51+
#### `unauthenticatedOnly`
52+
53+
Whether to only allow unauthenticated users to access this page. Authenticated users will be redirected to `/` or the route defined in `navigateAuthenticatedTo`
54+
55+
#### `navigateAuthenticatedTo`
56+
57+
Where to redirect authenticated users if `unauthenticatedOnly` is set to true
58+
59+
#### `navigateUnauthenticatedTo`
60+
61+
Where to redirect unauthenticated users if this page is protected
62+
4963
### Disabling the global middleware locally
5064

5165
To disable the global middleware on a specific page only, you can use the [`definePageMeta` macro](https://nuxt.com/docs/api/utils/define-page-meta#definepagemeta) to turn `auth` off:

0 commit comments

Comments
 (0)