Skip to content

Commit d54a91c

Browse files
committed
docs: initAuth PR from old docs
Closes feathers-plus/docs#55
1 parent b9bf3cc commit d54a91c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/nuxt.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ title: Nuxt
44

55
## Working with Auth & Nuxt
66

7-
`[email protected]` ships with utilities that help with Nuxt auth related to JSON Web Tokens (JWT). The most important utility is the `initAuth` utility. It's for use during Nuxt's `nuxtServerInit` method, and sets up auth data automatically. Here's an example store that uses it:
7+
`[email protected]^` ships with utilities that help with Nuxt auth related to JSON Web Tokens (JWT). The most important utility is the `initAuth` utility. It's for use during Nuxt's `nuxtServerInit` method, and sets up auth data automatically.
8+
9+
`initAuth` will do the following:
10+
1. Get the accessToken from the `req` passed in
11+
2. Get the payload from the token
12+
3. commit the token and payload to the store with `setAccessToken` and `setPayload`
13+
4. Set the access token on the feathers client instance so that the next time authenticate is called, it will have the JWT from the `req` to authenticate with the server.
14+
15+
Here's an example store that uses it:
816

917
```js
1018
import Vuex from 'vuex'
@@ -27,6 +35,7 @@ const createStore = () => {
2735
commit,
2836
dispatch,
2937
req,
38+
feathersClient,
3039
moduleName: 'auth',
3140
cookieName: 'feathers-jwt'
3241
})

0 commit comments

Comments
 (0)