Skip to content

Commit 98c8ae8

Browse files
fix(UniversalLogin): handle redirectTo upon auth failure (#6252)
* fix(UniversalLogin): handle redirectTo upon auth failure * chore: prettier
1 parent 3979c8d commit 98c8ae8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/onboarding/containers/CloudLoginPage.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,18 @@ export const CloudLoginPage: FC = () => {
5959
fetch('/api/env/quartz-login-url')
6060
.then(async response => {
6161
const quartzUrl = await response.text()
62-
const pathname = window.location.pathname ?? ''
62+
const redirectTo = new URLSearchParams(window.location.search).get(
63+
'redirectTo'
64+
)
65+
let pathname
66+
try {
67+
// if there is a redirectTo, parse the pathname from redirect location
68+
const redirectToUrl = new URL(redirectTo).pathname
69+
pathname = redirectToUrl ?? ''
70+
} catch {
71+
// else, use current location's pathname
72+
pathname = window.location.pathname ?? ''
73+
}
6374
const redirectUrl = quartzUrl + pathname
6475
console.warn('Redirect to cloud url: ', redirectUrl)
6576
window.location.replace(redirectUrl)

0 commit comments

Comments
 (0)