Skip to content

Commit

Permalink
fix: redirection to auth dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
meelrossi committed Jan 10, 2024
1 parent 6346397 commit ad7a0b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/SignInPage/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default class SignInPage extends React.PureComponent<Props> {

handleRedirectToAuthDapp = () => {
if (this.props.isAuthDappEnabled && !this.props.isConnected && !this.props.isConnecting) {
redirectToAuthDapp()
const params = new URLSearchParams(window.location.search)
const basename = /^decentraland.(zone|org|today)$/.test(window.location.host) ? '/builder' : ''
redirectToAuthDapp(`${basename}${params.get('redirectTo') || '/'}`)
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/routing/locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const locations = {
templateDetail: (templateId = ':templateId') => `/templates/${templateId}`
}

export function redirectToAuthDapp() {
window.location.replace(`${config.get('AUTH_URL')}/login?redirectTo=${encodeURIComponent(window.location.href)}`)
export function redirectToAuthDapp(customRedirect?: string) {
window.location.replace(
`${config.get('AUTH_URL')}/login?redirectTo=${encodeURIComponent(customRedirect ? customRedirect : window.location.href)}`
)
}

0 comments on commit ad7a0b4

Please sign in to comment.