File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,25 @@ export const useAuth = () => {
1313
1414 useEffect ( ( ) => {
1515 // Check for auth token and get user info
16- const token = localStorage . getItem ( 'authToken' )
16+ // Support both 'authToken' (legacy) and 'accessToken' (current)
17+ const token = localStorage . getItem ( 'accessToken' ) || localStorage . getItem ( 'authToken' )
1718
1819 if ( token ) {
1920 // Decode JWT or fetch user info
2021 try {
2122 // Simple JWT decode (in production, verify signature)
2223 const payload = JSON . parse ( atob ( token . split ( '.' ) [ 1 ] ) )
24+
25+ // Get DID from token or localStorage (wallet auth stores it separately)
26+ const did = payload . did || localStorage . getItem ( 'did' )
27+ const ethAddress = localStorage . getItem ( 'ethAddress' )
28+
2329 setCurrentUser ( {
2430 id : payload . userId || payload . id ,
2531 email : payload . email ,
2632 googleId : payload . googleId ,
27- metamaskAddress : payload . metamaskAddress
33+ // Use DID/ethAddress from token or localStorage for wallet auth
34+ metamaskAddress : ethAddress || ( did ? did . replace ( 'did:ethr:' , '' ) : undefined )
2835 } )
2936 } catch ( error ) {
3037 console . error ( 'Failed to decode token:' , error )
You can’t perform that action at this time.
0 commit comments