Skip to content

Commit 344920c

Browse files
feat(local scheme): add autoFetchUser option (#543)
1 parent ab75ebc commit 344920c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/schemes/local.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ auth: {
3535
},
3636
// tokenRequired: true,
3737
// tokenType: 'bearer'
38+
// autoFetchUser: true
3839
}
3940
}
4041
}
@@ -83,3 +84,9 @@ This option can be used to disable all token handling. Useful for Cookie only fl
8384
- Default: `Bearer`
8485

8586
Authorization header type to be used in axios requests.
87+
88+
### `autoFetchUser`
89+
90+
- Default: `true`
91+
92+
This option can be used to disable user fetch after login. It is useful when your login response already have the user.

lib/schemes/local.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export default class LocalScheme {
5151
this._setToken(token)
5252
}
5353

54-
return this.fetchUser()
54+
if (this.options.autoFetchUser) {
55+
await this.fetchUser()
56+
}
5557
}
5658

5759
async setUserToken (tokenValue) {
@@ -114,5 +116,6 @@ const DEFAULTS = {
114116
tokenRequired: true,
115117
tokenType: 'Bearer',
116118
globalToken: true,
117-
tokenName: 'Authorization'
119+
tokenName: 'Authorization',
120+
autoFetchUser: true
118121
}

0 commit comments

Comments
 (0)