File tree 4 files changed +7
-3
lines changed
4 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,17 @@ module.exports = class Provider extends RequestClient {
14
14
this . authProvider = opts . authProvider || this . provider
15
15
this . name = this . opts . name || _getName ( this . id )
16
16
this . tokenKey = `companion-${ this . id } -auth-token`
17
+ this . storage = opts . storage || localStorage
17
18
}
18
19
19
20
get defaultHeaders ( ) {
20
- return Object . assign ( { } , super . defaultHeaders , { 'uppy-auth-token' : localStorage . getItem ( this . tokenKey ) } )
21
+ return Object . assign ( { } , super . defaultHeaders , { 'uppy-auth-token' : this . storage . getItem ( this . tokenKey ) } )
21
22
}
22
23
23
24
// @todo (i.olarewaju) consider whether or not this method should be exposed
24
25
setAuthToken ( token ) {
25
26
// @todo (i.olarewaju) add fallback for OOM storage
26
- localStorage . setItem ( this . tokenKey , token )
27
+ this . storage . setItem ( this . tokenKey , token )
27
28
}
28
29
29
30
checkAuth ( ) {
@@ -48,7 +49,7 @@ module.exports = class Provider extends RequestClient {
48
49
logout ( redirect = location . href ) {
49
50
return this . get ( `${ this . id } /logout?redirect=${ redirect } ` )
50
51
. then ( ( res ) => {
51
- localStorage . removeItem ( this . tokenKey )
52
+ this . storage . removeItem ( this . tokenKey )
52
53
return res
53
54
} )
54
55
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ module.exports = class Dropbox extends Plugin {
20
20
this . provider = new Provider ( uppy , {
21
21
serverUrl : this . opts . serverUrl ,
22
22
serverHeaders : this . opts . serverHeaders ,
23
+ storage : this . opts . storage ,
23
24
provider : 'dropbox'
24
25
} )
25
26
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ module.exports = class GoogleDrive extends Plugin {
23
23
this . provider = new Provider ( uppy , {
24
24
serverUrl : this . opts . serverUrl ,
25
25
serverHeaders : this . opts . serverHeaders ,
26
+ storage : this . opts . storage ,
26
27
provider : 'drive' ,
27
28
authProvider : 'google'
28
29
} )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ module.exports = class Instagram extends Plugin {
20
20
this . provider = new Provider ( uppy , {
21
21
serverUrl : this . opts . serverUrl ,
22
22
serverHeaders : this . opts . serverHeaders ,
23
+ storage : this . opts . storage ,
23
24
provider : 'instagram' ,
24
25
authProvider : 'instagram'
25
26
} )
You can’t perform that action at this time.
0 commit comments