@@ -2013,17 +2013,34 @@ export default class GoTrueClient {
2013
2013
}
2014
2014
}
2015
2015
}
2016
+ } else if (
2017
+ currentSession . user &&
2018
+ ( currentSession . user as any ) . __isUserNotAvailableProxy === true
2019
+ ) {
2020
+ // If we have a proxy user, try to get the real user data
2021
+ try {
2022
+ const { data, error : userError } = await this . _getUser ( currentSession . access_token )
2023
+
2024
+ if ( ! userError && data ?. user ) {
2025
+ currentSession . user = data . user
2026
+ await this . _saveSession ( currentSession )
2027
+ await this . _notifyAllSubscribers ( 'SIGNED_IN' , currentSession )
2028
+ } else {
2029
+ this . _debug ( debugName , 'could not get user data, skipping SIGNED_IN notification' )
2030
+ }
2031
+ } catch ( getUserError ) {
2032
+ console . error ( 'Error getting user data:' , getUserError )
2033
+ this . _debug (
2034
+ debugName ,
2035
+ 'error getting user data, skipping SIGNED_IN notification' ,
2036
+ getUserError
2037
+ )
2038
+ }
2016
2039
} else {
2017
2040
// no need to persist currentSession again, as we just loaded it from
2018
2041
// local storage; persisting it again may overwrite a value saved by
2019
2042
// another client with access to the same local storage
2020
-
2021
- // Prevent sending a proxy user object as it can't be structured cloned
2022
- let finalPayloadSession =
2023
- currentSession . user && ( currentSession . user as any ) . __isUserNotAvailableProxy
2024
- ? null
2025
- : currentSession
2026
- await this . _notifyAllSubscribers ( 'SIGNED_IN' , finalPayloadSession )
2043
+ await this . _notifyAllSubscribers ( 'SIGNED_IN' , currentSession )
2027
2044
}
2028
2045
} catch ( err ) {
2029
2046
this . _debug ( debugName , 'error' , err )
0 commit comments