File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,19 @@ class Auth {
105
105
106
106
this . removeSavedSession = ( ) => {
107
107
this . currentUser = null
108
+ this . refreshToken = null
108
109
this . accessToken = this . supabaseKey
109
110
isBrowser ( ) && localStorage . removeItem ( storageKey )
110
111
}
111
112
113
+ this . authHeader = ( ) => {
114
+ let json = isBrowser ( ) && localStorage . getItem ( storageKey )
115
+ let persisted = json ? JSON . parse ( json ) : null
116
+ if ( persisted ?. accessToken ) return `Bearer ${ persisted . accessToken } `
117
+ else if ( this . accessToken ) return `Bearer ${ this . accessToken } `
118
+ else return null
119
+ }
120
+
112
121
this . recoverSession = ( ) => {
113
122
const json = isBrowser ( ) && localStorage . getItem ( storageKey )
114
123
if ( json ) {
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ class SupabaseClient {
91
91
initClient ( ) {
92
92
let headers = { apikey : this . supabaseKey }
93
93
94
- if ( this . auth . accessToken ) headers [ 'Authorization' ] = `Bearer ${ this . auth . accessToken } `
94
+ if ( this . auth . authHeader ( ) ) headers [ 'Authorization' ] = this . auth . authHeader ( )
95
95
96
96
let rest = new PostgrestClient ( this . restUrl , {
97
97
headers,
You can’t perform that action at this time.
0 commit comments