Skip to content

Commit 1d45b5b

Browse files
committed
Updated Application-side docs
1 parent 1af971e commit 1d45b5b

File tree

3 files changed

+20
-75
lines changed

3 files changed

+20
-75
lines changed

docs/guide/application-side/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The full url at which the app will run combined with the path to authentication.
6262
- **port**: _empty_ (implies `:80` for http and `:443` for https), :3000, :8888
6363
- **path**: the path that directs to the location of your `NuxtAuthHandler` e.g. `/api/auth`
6464

65-
### `local` and `refresh` Providers
65+
### `local` Provider
6666

6767
Defaults to `/api/auth` for both development and production. Setting this is optional, if you set it you can set it to either:
6868
- just a path: Will lead to `nuxt-auth` using `baseURL` as a relative path appended to the origin you deploy to. Example: `/backend/auth`
@@ -74,12 +74,12 @@ If you point to a different origin than the one you deploy to you likely have to
7474

7575
## `provider`
7676

77-
- **Type**: `ProviderAuthjs | ProviderLocal | ProviderRefresh`
77+
- **Type**: `ProviderAuthjs | ProviderLocal`
7878
- **Default**: `undefined`
7979

8080
Configuration of the authentication provider. Different providers are supported:
8181
- AuthJS: See [configuration options here](/guide/authjs/quick-start#configuration)
82-
- Local / Refresh: See [configuration options here](/guide/local/quick-start)
82+
- Local: See [configuration options here](/guide/local/quick-start)
8383

8484
## `sessionRefresh`
8585

docs/guide/application-side/session-access.md

Lines changed: 15 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,12 @@ const {
2727
data,
2828
lastRefreshedAt,
2929
token,
30-
getSession,
31-
signUp,
32-
signIn,
33-
signOut
34-
} = useAuth()
35-
```
36-
37-
```ts [refresh]
38-
const {
39-
status,
40-
data,
41-
lastRefreshedAt,
42-
token,
30+
refreshToken,
4331
getSession,
4432
signUp,
4533
signIn,
4634
signOut,
47-
refresh,
48-
refreshToken
35+
refresh
4936
} = useAuth()
5037
```
5138

@@ -86,7 +73,7 @@ const { data } = useAuth()
8673
</template>
8774
```
8875

89-
### `token`
76+
### `token` <Badge type="warning">local only</Badge>
9077

9178
The fetched token that can be used to authenticate further requests. This could be e.g. a JWT-Bearer token.
9279

@@ -103,15 +90,15 @@ function useAPI() {
10390
}
10491
```
10592

106-
:::warning Local / Refresh Only
107-
`token` is only avalible for the refresh and local providers!
93+
:::warning Local Only
94+
`token` is only avalible for the local provider!
10895
:::
10996

11097
### `lastRefreshedAt`
11198

11299
Time at which the session was last refreshed, either `undefined` if no refresh was attempted or a `Date` of the time the refresh happened.
113100

114-
### `getCsrfToken`
101+
### `getCsrfToken` <Badge type="warning">authjs only</Badge>
115102

116103
Returns the current Cross Site Request Forgery Token (CSRF Token) required to make POST requests (e.g. for signing in and signing out).
117104

@@ -121,7 +108,7 @@ You likely only need to use this if you are not using the built-in `signIn()` an
121108
`getCsrfToken` is only avalible for the authjs provider!
122109
:::
123110

124-
### `getProviders`
111+
### `getProviders` <Badge type="warning">authjs only</Badge>
125112

126113
Get a list of all the configured OAuth providers. Useful for creating a [custom login page](/guide/authjs/custom-pages#sign-in-page). Returns an array of `Provider`.
127114

@@ -158,7 +145,7 @@ const { getSession } = useAuth()
158145
</template>
159146
```
160147

161-
### `signUp`
148+
### `signUp` <Badge type="warning">local only</Badge>
162149

163150
```ts
164151
// `credentials` are the credentials your sign-up endpoint expects,
@@ -184,8 +171,8 @@ await signUp(credentials, undefined, { preventLoginFlow: true })
184171
You can also pass the `callbackUrl` option to redirect a user to a certain page, after they completed the action. This can be useful when a user attempts to open a page (`/protected`) but has to go through external authentication (e.g., via their google account) first.
185172
:::
186173

187-
:::warning Local / Refresh Only
188-
`signUp` is only avalible for the refresh and local providers!
174+
:::warning Local Only
175+
`signUp` is only avalible for the local provider!
189176
:::
190177

191178
### `signIn`
@@ -257,12 +244,12 @@ const { signOut } = useAuth()
257244
You can also pass the `callbackUrl` option to redirect a user to a certain page, after they completed the action. This can be useful when a user attempts to open a page (`/protected`) but has to go through external authentication (e.g., via their google account) first.
258245
:::
259246

260-
### `refreshToken`
247+
### `refreshToken` <Badge type="warning">local only</Badge>
261248

262249
The fetched refreshToken that can be used to obtain a new access token . E.g. a refreshToken looks like this: `eyDFSJKLDAJ0-3249PPRFK3P5234SDFL;AFKJlkjdsjd.dsjlajhasdji89034`
263250

264-
:::warning Refresh Only
265-
`refreshToken` is only avalible for the refresh provider!
251+
:::warning Local Only
252+
`refreshToken` is only avalible for the local provider!
266253
:::
267254

268255
### `refresh`
@@ -297,43 +284,6 @@ lastRefreshedAt.value
297284
```
298285

299286
```ts [local]
300-
const {
301-
status,
302-
loading,
303-
data,
304-
lastRefreshedAt,
305-
token,
306-
rawToken,
307-
setToken,
308-
clearToken
309-
} = useAuthState()
310-
311-
// Session status, either `unauthenticated`, `loading`, `authenticated`
312-
status.value
313-
314-
// Whether any http request is still pending
315-
loading.value
316-
317-
// Session data, either `undefined` (= authentication not attempted), `null` (= user unauthenticated), or session / user data your `getSession`-endpoint returns
318-
data.value
319-
320-
// Time at which the session was last refreshed, either `undefined` if no refresh was attempted or a `Date` of the time the refresh happened
321-
lastRefreshedAt.value
322-
323-
// The fetched token that can be used to authenticate future requests. E.g., a JWT-Bearer token like so: `Bearer eyDFSJKLDAJ0-3249PPRFK3P5234SDFL;AFKJlkjdsjd.dsjlajhasdji89034`
324-
token.value
325-
326-
// Cookie that containes the raw fetched token string. This token won't contain any modification or prefixes like `Bearer` or any other.
327-
rawToken.value
328-
329-
// Helper method to quickly set a new token (alias for rawToken.value = 'xxx')
330-
setToken('new token')
331-
332-
// Helper method to quickly delete the token cookie (alias for rawToken.value = null)
333-
clearToken()
334-
```
335-
336-
```ts [refresh]
337287
const {
338288
status,
339289
loading,
@@ -362,24 +312,18 @@ lastRefreshedAt.value
362312
// The fetched token that can be used to authenticate future requests. E.g., a JWT-Bearer token like so: `Bearer eyDFSJKLDAJ0-3249PPRFK3P5234SDFL;AFKJlkjdsjd.dsjlajhasdji89034`
363313
token.value
364314

365-
// The fetched refreshToken that can be used to refresh the Token with refresh() methode.
366-
refreshToken.value
367-
368315
// Cookie that containes the raw fetched token string. This token won't contain any modification or prefixes like `Bearer` or any other.
369316
rawToken.value
370317

371-
// Cookie that containes the raw fetched refreshToken string.
372-
rawRefreshToken.value
373-
374318
// Helper method to quickly set a new token (alias for rawToken.value = 'xxx')
375319
setToken('new token')
376320

377-
// Helper method to quickly delete the token and refresh Token cookie (alias for rawToken.value = null and rawRefreshToken.value = null)
321+
// Helper method to quickly delete the token cookie (alias for rawToken.value = null)
378322
clearToken()
379323
```
380324
:::
381325

382-
:::warning Local and refresh providers:
326+
:::warning Local provider:
383327
Note that you will have to manually call getSession from useAuth composable in order to refresh the new user state when using setToken, clearToken or manually updating rawToken.value:
384328
:::
385329

playground-local/app.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { ref } from 'vue'
33
import { useAuth } from '#imports'
44
5-
const { signIn, token, data, status, lastRefreshedAt, signOut, getSession } = useAuth()
5+
const { signIn, token, refreshToken, data, status, lastRefreshedAt, signOut, getSession } = useAuth()
66
77
const username = ref('')
88
const password = ref('')
@@ -14,6 +14,7 @@ const password = ref('')
1414
<pre>Data: {{ data || 'no session data present, are you logged in?' }}</pre>
1515
<pre>Last refreshed at: {{ lastRefreshedAt || 'no refresh happened' }}</pre>
1616
<pre>JWT token: {{ token || 'no token present, are you logged in?' }}</pre>
17+
<pre>Refresh token: {{ refreshToken || 'N/A' }}</pre>
1718

1819
<form @submit.prevent="signIn({ username, password })">
1920
<input v-model="username" type="text" placeholder="Username" data-testid="username">

0 commit comments

Comments
 (0)