Skip to content

Commit

Permalink
fix: Redirect to auth if no connection (#441)
Browse files Browse the repository at this point in the history
* fix: Redirect to auth if no connection

* fix: Only add skip setup once
  • Loading branch information
LautaroPetaccio authored Jan 11, 2024
1 parent b0f6e75 commit 8c1fbe4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/start/Start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import './Start.css'

function getAuthURL() {
var url = new URL(window.location.href)
url.searchParams.append('skipSetup', 'true')
if (!url.searchParams.has('skipSetup')) {
url.searchParams.append('skipSetup', 'true')
}
return `/auth/login?redirectTo=${encodeURIComponent(url.toString())}`
}

Expand All @@ -41,7 +43,10 @@ export default function Start(props: Props) {
}, [isConnecting])

useEffect(() => {
if (!isConnected && !isConnecting && initialized) {
if (
(!isConnected && !isConnecting && initialized) ||
localStorage.getItem('decentraland-connect-storage-key') === null
) {
window.location.replace(getAuthURL())
return
}
Expand Down

0 comments on commit 8c1fbe4

Please sign in to comment.