Skip to content

Commit

Permalink
feat(local scheme): add autoFetchUser option (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedroAS51 authored Mar 3, 2020
1 parent ab75ebc commit 344920c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/schemes/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ auth: {
},
// tokenRequired: true,
// tokenType: 'bearer'
// autoFetchUser: true
}
}
}
Expand Down Expand Up @@ -83,3 +84,9 @@ This option can be used to disable all token handling. Useful for Cookie only fl
- Default: `Bearer`

Authorization header type to be used in axios requests.

### `autoFetchUser`

- Default: `true`

This option can be used to disable user fetch after login. It is useful when your login response already have the user.
7 changes: 5 additions & 2 deletions lib/schemes/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export default class LocalScheme {
this._setToken(token)
}

return this.fetchUser()
if (this.options.autoFetchUser) {
await this.fetchUser()
}
}

async setUserToken (tokenValue) {
Expand Down Expand Up @@ -114,5 +116,6 @@ const DEFAULTS = {
tokenRequired: true,
tokenType: 'Bearer',
globalToken: true,
tokenName: 'Authorization'
tokenName: 'Authorization',
autoFetchUser: true
}

0 comments on commit 344920c

Please sign in to comment.