Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refresh support #361

Merged
merged 131 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
c901e85
squash pr/325
May 25, 2019
26df860
revert remember leftovers
May 25, 2019
6cdb8fa
fix: use customizable property instead of getRealName
JoaoPedroAS51 May 25, 2019
8a3340e
feat(examples): add refresh example
JoaoPedroAS51 May 25, 2019
b755400
fix(local scheme): remove undefined cookieOptions
JoaoPedroAS51 May 25, 2019
88185d3
fix lint error
May 25, 2019
3cc2875
prefer arrow function
May 25, 2019
35cf92d
extra param
May 25, 2019
de5d4e0
refactor _updateTokens
May 25, 2019
5ceec72
options leftover from rememberme
May 25, 2019
b7bef6a
refactor strategy options into local.js
May 25, 2019
9809cc9
refactor(local scheme): remove refresh endpoint
JoaoPedroAS51 May 25, 2019
35772af
fix(refresh example): fix data properties
JoaoPedroAS51 May 25, 2019
5e3b5de
fix(refresh example): add missing dataGrantTypeProperty
JoaoPedroAS51 May 25, 2019
9045f3e
refactor(demo): remove leftover from rememberme
JoaoPedroAS51 May 27, 2019
5b8b57b
refactor: deprecate propertyName in favour of top level options
JoaoPedroAS51 May 28, 2019
19f3131
refactor: update demo to use tokenProperty and refreshTokenProperty
JoaoPedroAS51 May 28, 2019
da12c9b
fix: add compatibility to propertyName of user endpoint
JoaoPedroAS51 May 28, 2019
23980d7
refactor: omit `*Property` from options
JoaoPedroAS51 May 31, 2019
edcf30f
refactor: refactor token and refreshToken options into object and mov…
JoaoPedroAS51 May 31, 2019
aac98c0
refactor: remove compatibility with propertyName and add warn to aler…
JoaoPedroAS51 May 31, 2019
791b2eb
refactor: rename disableAutoRefresh to enableAutoRefresh and disable …
JoaoPedroAS51 May 31, 2019
1a510c2
refactor: refactor autoRefresh into object
JoaoPedroAS51 May 31, 2019
dc98bca
Merge remote-tracking branch 'upstream/dev' into feat/refresh
JoaoPedroAS51 Jun 2, 2019
c4f0440
feat(demo): improve refresh endpoint
JoaoPedroAS51 Jun 6, 2019
c416fd4
refactor(storage): prefer cookie over local state on syncUniversal
JoaoPedroAS51 Jun 6, 2019
ee82e15
fix(refresh scheme): sync tokens before refresh
JoaoPedroAS51 Jun 6, 2019
35744ea
feat(refresh scheme): add request interceptor and refresh token expir…
JoaoPedroAS51 Jun 11, 2019
3f02691
fix: fix lint error
JoaoPedroAS51 Jun 11, 2019
ea6558b
fix(refresh scheme): update header after sync tokens on request inter…
JoaoPedroAS51 Jun 12, 2019
c1ceea2
fix(refresh scheme): fix check of token expiration on request interce…
JoaoPedroAS51 Jun 13, 2019
f129c3a
fix(refresh scheme): support multiple requests on request interceptor
JoaoPedroAS51 Jun 13, 2019
11332ba
fix(refresh scheme): fix check of token expiration on mount
JoaoPedroAS51 Jun 13, 2019
23b1f9c
refactor(refresh scheme): remove unnecessary "_syncTokenExpiration"
JoaoPedroAS51 Jun 13, 2019
02aac24
fix(refresh scheme): fix check of token expiration on mount
JoaoPedroAS51 Jun 13, 2019
e0e2f09
fix(refresh scheme): allow refresh token max age to be false
JoaoPedroAS51 Jul 3, 2019
55c2949
Merge remote-tracking branch 'upstream/dev' into feat/refresh
JoaoPedroAS51 Jul 11, 2019
d185b6e
feat(refresh scheme): add property autoLogout to logout on mount if t…
JoaoPedroAS51 Jul 11, 2019
25080b0
fix(refresh scheme): initialize request interceptor before fetch user
JoaoPedroAS51 Jul 11, 2019
c821951
fix(refresh scheme): fix logout on mount
JoaoPedroAS51 Jul 11, 2019
e8ef414
fix(refresh scheme): fix logout on mount
JoaoPedroAS51 Jul 12, 2019
080628f
fix(refresh scheme): wait for refresh token request, even if token ha…
JoaoPedroAS51 Jul 12, 2019
d061ad5
fix(refresh scheme): fix server side error "Invalid value 'undefined'…
JoaoPedroAS51 Jul 25, 2019
9d332ee
fix: set "false" as default value of "getUniversal" method
JoaoPedroAS51 Jul 25, 2019
226203f
revert: "fix: set "false" as default value of "getUniversal" method"
JoaoPedroAS51 Jul 25, 2019
65822b2
fix(refresh scheme): fix hasRefreshTokenChanged property that was giv…
JoaoPedroAS51 Jul 26, 2019
6a13a15
Merge branch 'dev' into feat/refresh
atinux Sep 10, 2019
50c0fc7
fix: move config.headers set after the check
atinux Sep 10, 2019
59ce5f7
Avoid rejecting promise from refresh token check (#454)
gaetansenn Sep 17, 2019
c58e421
Merge remote-tracking branch 'upstream/dev' into feat/refresh
JoaoPedroAS51 Feb 23, 2020
dbf6499
fix(core): remove old getProp
JoaoPedroAS51 Feb 23, 2020
901cdfc
fix(refresh scheme): fix code linting
JoaoPedroAS51 Feb 23, 2020
18b03ef
refactor: refactor 'clientId' into local and refresh schemes
JoaoPedroAS51 Feb 28, 2020
705ff5b
test: fix token property
JoaoPedroAS51 Feb 28, 2020
adb1d19
docs(local scheme): update use of property name
JoaoPedroAS51 Feb 29, 2020
d049388
docs(refresh scheme): add refresh scheme docs
JoaoPedroAS51 Feb 29, 2020
5039db5
test: add refresh test
JoaoPedroAS51 Feb 29, 2020
f0cf940
refactor: refactor refresh token helpers into core
JoaoPedroAS51 Mar 1, 2020
e07b078
refactor(refresh scheme): rename method tokenRefresh to refreshToken
JoaoPedroAS51 Mar 1, 2020
6082652
feat(core): add refresh token method
JoaoPedroAS51 Mar 1, 2020
2438182
feat(demo): add refresh token button
JoaoPedroAS51 Mar 1, 2020
c21e17b
docs(api): add 'setRefreshToken' and 'refreshToken' methods
JoaoPedroAS51 Mar 1, 2020
04a3473
docs(refresh scheme): update description and usage
JoaoPedroAS51 Mar 1, 2020
c892cc9
fix(refresh): reset refresh timer if refreshToken is called manually
JoaoPedroAS51 Mar 1, 2020
04c97ba
chore(deps): add dependency jwt-decode
JoaoPedroAS51 Mar 1, 2020
f2e6e33
refactor(refresh scheme): use jwtDecode to get token expiration
JoaoPedroAS51 Mar 1, 2020
d11fb10
docs(refresh scheme): update autoRefresh description
JoaoPedroAS51 Mar 1, 2020
0f09ce2
refactor(refresh scheme): use token property to decode
JoaoPedroAS51 Mar 1, 2020
d155416
test(refresh): fix refreshed token expiration test
JoaoPedroAS51 Mar 1, 2020
78e1090
fix(refresh scheme): remove error instance check
JoaoPedroAS51 Mar 1, 2020
437af1a
Merge branch 'dev' into feat/refresh
JoaoPedroAS51 Mar 2, 2020
0f8bea4
refactor(refresh scheme): remove 'tokenRequired' option
JoaoPedroAS51 Mar 3, 2020
67c8576
docs(refresh scheme): remove 'tokenRequired' option
JoaoPedroAS51 Mar 3, 2020
9cb65be
fix(local scheme): move 'syncClientId' to outside of 'tokenRequired' …
JoaoPedroAS51 Mar 3, 2020
b2937ab
fix(refresh scheme): handle errors
JoaoPedroAS51 Mar 3, 2020
02daa79
fix(refresh scheme): fix reset
JoaoPedroAS51 Mar 3, 2020
457ceac
fix(refresh scheme): reset only if 'resetOnError' is enabled
JoaoPedroAS51 Mar 3, 2020
3e3a693
Merge branch 'dev' into feat/refresh
JoaoPedroAS51 Mar 3, 2020
5e86e5b
fix(local scheme): fix lint error
JoaoPedroAS51 Mar 3, 2020
d53338d
fix(core): reset refresh token by default
JoaoPedroAS51 Mar 3, 2020
7814500
fix(local scheme): remove refresh token reset
JoaoPedroAS51 Mar 3, 2020
0995340
Merge branch 'dev' into feat/refresh
JoaoPedroAS51 Mar 3, 2020
b4137eb
fix(refresh scheme): only fetch user if 'autoFetchUser' is enabled
JoaoPedroAS51 Mar 3, 2020
2980892
fix(refresh scheme): return login response
JoaoPedroAS51 Mar 3, 2020
745d52c
test(refresh): expect login response
JoaoPedroAS51 Mar 3, 2020
60c12ef
Merge branch 'dev' into feat/refresh
JoaoPedroAS51 Mar 3, 2020
98a2a6b
fix: return response from `refreshToken` method
JoaoPedroAS51 Mar 3, 2020
c307e52
test(refresh): expect refreshed response
JoaoPedroAS51 Mar 3, 2020
6d0ce64
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 8, 2020
a648ad0
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 8, 2020
b560e06
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 8, 2020
ac78c31
feat(refresh scheme): use Refresh Controller and Token Status Expiration
JoaoPedroAS51 Mar 9, 2020
4e62b15
fix(refresh scheme): pass refresh endpoint url to `initializeRequestI…
JoaoPedroAS51 Mar 9, 2020
1eaa002
docs(refresh scheme): fix description of token and refresh token `max…
JoaoPedroAS51 Mar 9, 2020
3335df7
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 9, 2020
44c4db6
refactor(refresh scheme): refactor based on merged commits from `feat…
JoaoPedroAS51 Mar 9, 2020
18129e5
test(refresh): refactor based on merged commits from `feat/refresh-core`
JoaoPedroAS51 Mar 9, 2020
e14e0cc
demo(refresh): refactor based on merged commits from `feat/refresh-core`
JoaoPedroAS51 Mar 9, 2020
46ceb2b
docs(refresh scheme): refactor based on merged commits from `feat/ref…
JoaoPedroAS51 Mar 9, 2020
29c678e
fix(refresh scheme): remove unnecessary param
JoaoPedroAS51 Mar 9, 2020
b09de9a
fix(refresh scheme): reset Refresh Controller
JoaoPedroAS51 Mar 9, 2020
f735c36
fix(refresh scheme): only add grantType to refresh token request if `…
JoaoPedroAS51 Mar 13, 2020
fea5fe9
refactor(schemes): set default values of `dataClientId` and `dataGran…
JoaoPedroAS51 Mar 13, 2020
2d09c29
docs(refresh scheme): update default values of `dataClientId` and `da…
JoaoPedroAS51 Mar 13, 2020
6673c23
fix(refresh scheme): check if refresh token is defined before attempt…
JoaoPedroAS51 Mar 13, 2020
bf0a38c
fix(refresh scheme): check if refresh token is not expired before att…
JoaoPedroAS51 Mar 13, 2020
21e40dc
fix(refresh scheme): sync status before attempting to refresh
JoaoPedroAS51 Mar 13, 2020
fe54f88
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 13, 2020
43d1803
refactor(defaults): remove local property
JoaoPedroAS51 Mar 13, 2020
dc52fb0
refactor(local scheme): organize default properties
JoaoPedroAS51 Mar 13, 2020
9af7417
feat(refresh scheme): refactor based on merged commits from `feat/ref…
JoaoPedroAS51 Mar 13, 2020
4484443
test(refresh): refactor based on merged commits from `feat/refresh-core`
JoaoPedroAS51 Mar 13, 2020
f7f6b78
demo(nuxt config): remove deprecated property `expiresIn`
JoaoPedroAS51 Mar 13, 2020
2391ce4
refactor(refresh scheme): organize default properties
JoaoPedroAS51 Mar 13, 2020
7eb9e9c
docs(refresh scheme): update docs based on merged commits from `feat/…
JoaoPedroAS51 Mar 13, 2020
dba79c4
refactor(schemes): deprecate `clientId`, `dataClientId`, `grantType`,…
JoaoPedroAS51 Mar 13, 2020
b025b96
docs(refresh scheme): deprecate `clientId`, `dataClientId`, `grantTyp…
JoaoPedroAS51 Mar 13, 2020
8e3505c
demo(refresh): deprecate `clientId`, `dataClientId`, `grantType`, `da…
JoaoPedroAS51 Mar 13, 2020
11d79c3
test: deprecate `clientId`, `dataClientId`, `grantType`, `dataGrantTy…
JoaoPedroAS51 Mar 13, 2020
831eef3
demo: remove deprecated property `expiresIn` from response
JoaoPedroAS51 Mar 13, 2020
c83c6f4
test: remove deprecated property `expiresIn`
JoaoPedroAS51 Mar 13, 2020
0af3e7e
fix(schemes): fix client id prefix
JoaoPedroAS51 Mar 13, 2020
92206df
demo: fix refresh tokens method
JoaoPedroAS51 Mar 13, 2020
78aca5e
demo: hide refresh token card if current strategy isn't `localRefresh`
JoaoPedroAS51 Mar 13, 2020
f9df49e
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 14, 2020
acd82b7
demo: set token and refresh token `maxAge`
JoaoPedroAS51 Mar 14, 2020
f4dcb25
test: set token and refresh token `maxAge`
JoaoPedroAS51 Mar 14, 2020
70755fd
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 14, 2020
b062721
Merge branch 'feat/refresh-core' into feat/refresh
JoaoPedroAS51 Mar 14, 2020
c2cb05e
fix(refresh scheme) require token to fetch user
JoaoPedroAS51 Mar 14, 2020
ef73a52
Merge branch 'dev' into feat/refresh
Mar 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
collapsable: false,
children: [
'/schemes/local',
'/schemes/refresh',
'/schemes/oauth2'
]
},
Expand Down
22 changes: 22 additions & 0 deletions docs/api/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ Universally set token. The `name` parameter is optional and defaults to `options
this.$auth.setToken('local', '.....')
```

### `setRefreshToken(strategy, token)`

Universally set refresh token.

```js
// Update refresh token
this.$auth.setRefreshToken('local', '.....')
```

### `refreshToken()`

Refreshes the token.



> **TIP:** Useful to manually refresh the token when [autoRefresh](../schemes/refresh.md#autorefresh) is disabled

```js
// Refresh the token
this.$auth.refreshToken()
```

### `onError(handler)`

Listen for auth errors: (`plugins/auth.js`)
Expand Down
21 changes: 17 additions & 4 deletions docs/schemes/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ Example for a token based flow:
auth: {
strategies: {
local: {
token: {
property: 'token'
},
user: 'user',
endpoints: {
login: { url: '/api/auth/login', method: 'post', propertyName: 'token' },
login: { url: '/api/auth/login', method: 'post' },
logout: { url: '/api/auth/logout', method: 'post' },
user: { url: '/api/auth/user', method: 'get', propertyName: 'user' }
user: { url: '/api/auth/user', method: 'get' }
},
// tokenRequired: true,
// tokenType: 'bearer'
Expand Down Expand Up @@ -65,9 +69,18 @@ Each endpoint is used to make requests using axios. They are basically extending
To disable each endpoint, simply set it's value to `false`.
:::

#### `propertyName`
### `token`

Here you configure the token options.

#### `property`

`property` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.token`.

### `user`

`user` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.user`.

`propertyName` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.user`.

### `tokenRequired`

Expand Down
222 changes: 222 additions & 0 deletions docs/schemes/refresh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Refresh

[Source Code](https://github.com/nuxt-community/auth-module/blob/dev/lib/schemes/refresh.js)

`refresh` is an extended version of `local` scheme, made for systems that use token refresh.

You can set `_scheme` to `refresh` to enable it.

## Usage

To do a password based login by sending credentials in request body as a JSON object:

```js
this.$auth.loginWith('local', {
data: {
username: 'your_username',
password: 'your_password'
}
})
```

To manually refresh the token:

```js
this.$auth.refreshToken()
```

Or enable [autoRefresh](#autorefresh) option to automatically refresh tokens.

## Options

Example for a token based flow:

```js
auth: {
strategies: {
local: {
_scheme: 'refresh',
token: {
property: 'access_token'
},
expiresIn: 'expires_in',
refreshToken: {
property: 'refresh_token'
},
user: 'user',
endpoints: {
login: { url: '/api/auth/login', method: 'post' },
refresh: { url: '/api/auth/refresh', method: 'post' },
user: { url: '/api/auth/user', method: 'get' },
logout: { url: '/api/auth/logout', method: 'post' }
},
// tokenType: 'bearer'
}
}
}
```

Example of auto refresh usage:

```js
auth: {
strategies: {
local: {
_scheme: 'refresh',
token: {
property: 'access_token'
},
expiresIn: 'expires_in',
refreshToken: {
property: 'refresh_token'
},
user: 'user',
endpoints: {
login: { url: '/api/auth/login', method: 'post' },
refresh: { url: '/api/auth/refresh', method: 'post' },
user: { url: '/api/auth/user', method: 'get' },
logout: { url: '/api/auth/logout', method: 'post' }
},
autoRefresh: {
enable: true
},
autoLogout: true,
// tokenType: 'bearer'
}
}
}
```

### `endpoints`

Each endpoint is used to make requests using axios. They are basically extending Axios [Request Config](https://github.com/axios/axios#request-config).

::: tip
To disable each endpoint, simply set it's value to `false`.
:::

### `token`

Here you configure the token options.

#### `property`

`property` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.token`.

#### `maxAge`

- Default: `1800`

Different from [expiresIn](#expiresin), here you set the default expiration time of the token, in **milliseconds**.
This time will be used if for some reason we couldn't get the value of [expiresIn](#expiresin).

By default its value is 30 minutes.

### `expiresIn`

This is the token expiration time, in **milliseconds**. We will use this value to automatically generate the expiration date if we couldn't decode the token.

`expiresIn` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.expires_in`

### `issuedAt`

`issuedAt` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.created_at`

By default we try to decode the token, if we couldn't decode the token we will automatically generate the issue date if `issuedAt` is not defined.

### `expiresAt`

`expiresAt` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.created_at`

By default we try to decode the token, if we couldn't decode the token we will automatically generate the expiration date using the [expiresIn](#expiresin) and [issuedAt](#issuedat) values if `expiresAt` is not defined.

### `refreshToken`

Here you configure the refresh token options.

#### `property`

`property` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.refresh_token`.

#### `maxAge`

- Default: `60 * 60 * 24 * 30`

Here you set the expiration time of the refresh token, in **milliseconds**.
You can set it to `false` if your refresh token doesn't expire.

### `dataRefreshToken`

- Default: `refresh_token`

`dataRefreshToken` can be used to set the name of the property you want to send in the request.

If you don't need it, you can set it to `false`.

### `user`

`user` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.user`.

### `clientId`

`clientId` can be used to specify which field of the response JSON to be used for value. It can be `false` to directly use API response or being more complicated like `auth.client_id`

This option is for systems that uses client id. If you don't use client id, you can set it to `false`.

### `dataClientId`

- Default: `client_id`

`dataClientId` can be used to set the name of the property you want to send in the request.

This option is for systems that uses client id. If you don't use client id, you can set it to `false`.

### `grantType`

- Default: `refresh_token`

It's the value of the grant type you want.

This option is for systems that uses grant type. If you don't use grant type, you can set it to `false`.

### `dataGrantType`

- Default: `grant_type`

`dataGrantType` can be used to set the name of the property you want to send in the request.

This option is for systems that uses grant type. If you don't use grant type, you can set it to `false`.

### `autoRefresh`

Here you configure the auto refresh options.

When enabled it will refresh the token before it expires. The auto refresh will happen when the time reach 75% of the expiration time or when the page is reloaded.

#### `enable`

- Default: `false`

This option enables auto refresh.

### `autoLogout`

- Default: `false`

This option will logout the user on load the page, if token has expired.

::: tip
Mostly used with [`autoRefresh`](#autorefresh).
:::

### `tokenName`

- Default: `Authorization`

Authorization header name to be used in axios requests.

### `tokenType`

- Default: `Bearer`

Authorization header type to be used in axios requests.
63 changes: 59 additions & 4 deletions examples/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ app.use(
jwt({
secret: 'dummy'
}).unless({
path: '/api/auth/login'
path: ['/api/auth/login', '/api/auth/refresh']
})
)

// Refresh tokens
const refreshTokens = {}

// -- Routes --

// [POST] /login
app.post('/login', (req, res, next) => {
const { username, password } = req.body
const valid = username.length && password === '123'
const expiresIn = 15
const refreshToken = Math.floor(Math.random() * (1000000000000000 - 1 + 1)) + 1

if (!valid) {
throw new Error('Invalid username or password')
Expand All @@ -37,17 +42,67 @@ app.post('/login', (req, res, next) => {
picture: 'https://github.com/nuxt.png',
name: 'User ' + username,
scope: ['test', 'user']
},
'dummy'
}, 'dummy', {
expiresIn
}
)

refreshTokens[refreshToken] = {
accessToken,
user: {
username,
picture: 'https://github.com/nuxt.png',
name: 'User ' + username
}
}

res.json({
token: {
accessToken
accessToken,
refreshToken,
expiresIn,
clientId: '123'
}
})
})

app.post('/refresh', (req, res, next) => {
const { refreshToken } = req.body

if ((refreshToken in refreshTokens)) {
const user = refreshTokens[refreshToken].user
const expiresIn = 15
const newRefreshToken = Math.floor(Math.random() * (1000000000000000 - 1 + 1)) + 1
delete refreshTokens[refreshToken]
const accessToken = jsonwebtoken.sign(
{
user: user.username,
picture: 'https://github.com/nuxt.png',
name: 'User ' + user.username,
scope: ['test', 'user']
}, 'dummy', {
expiresIn
}
)

refreshTokens[newRefreshToken] = {
accessToken,
user: user,
clientId: '123'
}

res.json({
token: {
accessToken,
refreshToken: newRefreshToken,
expiresIn
}
})
} else {
res.sendStatus(401)
}
})

// [GET] /user
app.get('/user', (req, res, next) => {
res.json({ user: req.user })
Expand Down
Loading