File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ Sets the global settings for store **logout** action.
71
71
* **name** - Set the token name in the local storage.
72
72
* **cookieName** - Set the token name in Cookies. (Set to ` null ` to disable)
73
73
* **type** - Sets the token type of the authorization header.
74
+ * **localStorage** - Decide whether to use or not the LocalStorage (default **true**).
74
75
75
76
#### redirect
76
77
* **notLoggedIn** - Sets the redirect URL default of the users not logged in. Only when ` auth` middleware is added to a page.
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ module.exports = function (moduleOptions) {
23
23
enabled : true ,
24
24
name : 'token' ,
25
25
cookieName : 'token' ,
26
- type : 'Bearer'
26
+ type : 'Bearer' ,
27
+ localStorage : true
27
28
}
28
29
}
29
30
Original file line number Diff line number Diff line change @@ -42,13 +42,15 @@ export default {
42
42
this . $axios . setToken ( token , '<%= options.token.type %>' ) ;
43
43
44
44
// Update localStorage
45
- if ( process . browser && localStorage ) {
46
- if ( token ) {
47
- localStorage . setItem ( '<%= options.token.name %>' , token )
48
- } else {
49
- localStorage . removeItem ( '<%= options.token.name %>' )
45
+ < % if ( options . token . localStorage ) { % >
46
+ if ( process . browser && localStorage ) {
47
+ if ( token ) {
48
+ localStorage . setItem ( '<%= options.token.name %>' , token )
49
+ } else {
50
+ localStorage . removeItem ( '<%= options.token.name %>' )
51
+ }
50
52
}
51
- }
53
+ < % } % >
52
54
53
55
< % if ( options . token . cookieName ) { % >
54
56
// Update cookies
@@ -82,9 +84,11 @@ export default {
82
84
let token
83
85
84
86
// Try to extract token from localStorage
85
- if ( process . browser && localStorage ) {
86
- token = localStorage . getItem ( '<%= options.token.name %>' )
87
- }
87
+ < % if ( options . token . localStorage ) { % >
88
+ if ( process . browser && localStorage ) {
89
+ token = localStorage . getItem ( '<%= options.token.name %>' )
90
+ }
91
+ < % } % >
88
92
89
93
< % if ( options . token . cookieName ) { % >
90
94
// Try to extract token from cookies
You can’t perform that action at this time.
0 commit comments