-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correctly redirect user to the request page (#116)
* fix: Correctly redirect user to the request page * fix: Redirect user to log in with redirect to when setting up * fix: Use toSetupPage * fix: Add getCurrentConnectionData function * fix: Restore setup page redirect
- Loading branch information
1 parent
9b93830
commit c49b6a3
Showing
4 changed files
with
69 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AuthIdentity } from '@dcl/crypto' | ||
import { localStorageGetIdentity } from '@dcl/single-sign-on-client' | ||
import { ConnectionResponse, connection } from 'decentraland-connect' | ||
|
||
export type DefinedConnectionResponse = Omit<ConnectionResponse, 'account'> & { account: string } | ||
export type ConnectionData = DefinedConnectionResponse & { identity: AuthIdentity } | ||
|
||
/** | ||
* Gets the current connection data. | ||
* @returns {Promise<ConnectionData | null>} The connection data or null if the user isn't connected or has no identity. | ||
*/ | ||
export const getCurrentConnectionData = async (): Promise<ConnectionData | null> => { | ||
try { | ||
const previousConnection = await connection.tryPreviousConnection() | ||
if (previousConnection.account && previousConnection.provider) { | ||
const identity = localStorageGetIdentity(previousConnection.account) | ||
if (identity) { | ||
return { ...(previousConnection as DefinedConnectionResponse), identity } | ||
} | ||
} | ||
return null | ||
} catch (error) { | ||
return null | ||
} | ||
} |