Skip to content

Commit 242837d

Browse files
committed
fix(docs): fix decorateUrl bugs in navigate callback examples
- Use `url` variable instead of hardcoded '/' in else branch (legacy/application-invitations) - Replace `router.push` with `window.location.href` in vanilla JS examples (multi-session, clerk.mdx) - Add missing `return` after currentTask check to prevent fall-through navigation - Remove `window.location.href` from Expo examples where it doesn't exist in React Native
1 parent b09a061 commit 242837d

File tree

9 files changed

+12
-27
lines changed

9 files changed

+12
-27
lines changed

docs/_partials/expo/email-pass-sign-in.mdx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ export default function Page() {
2828
if (signIn.status === 'complete') {
2929
await signIn.finalize({
3030
navigate: ({ decorateUrl }) => {
31-
const url = decorateUrl('/')
32-
if (url.startsWith('http')) {
33-
window.location.href = url
34-
} else {
35-
router.push(url)
36-
}
31+
router.push(decorateUrl('/'))
3732
},
3833
})
3934
}
@@ -50,12 +45,7 @@ export default function Page() {
5045
if (signIn.status === 'complete') {
5146
await signIn.finalize({
5247
navigate: ({ decorateUrl }) => {
53-
const url = decorateUrl('/')
54-
if (url.startsWith('http')) {
55-
window.location.href = url
56-
} else {
57-
router.push(url)
58-
}
48+
router.push(decorateUrl('/'))
5949
},
6050
})
6151
}

docs/_partials/expo/email-pass-sign-up.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ export default function Page() {
3636
if (signUp.status === 'complete') {
3737
await signUp.finalize({
3838
navigate: ({ decorateUrl }) => {
39-
const url = decorateUrl('/')
40-
if (url.startsWith('http')) {
41-
window.location.href = url
42-
} else {
43-
router.push(url)
44-
}
39+
router.push(decorateUrl('/'))
4540
},
4641
})
4742
}

docs/guides/development/custom-flows/authentication/legacy/application-invitations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ To create a sign-up flow using the invitation token, you need to extract the tok
237237
if (url.startsWith('http')) {
238238
window.location.href = url
239239
} else {
240-
window.location.href = '/'
240+
window.location.href = url
241241
}
242242
},
243243
})

docs/guides/development/custom-flows/authentication/legacy/email-password.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ This guide will walk you through how to build a custom email/password sign-up an
9797
// Handle session tasks
9898
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
9999
console.log(session?.currentTask)
100+
return
100101
}
101102

102103
const url = decorateUrl('/')

docs/guides/development/custom-flows/authentication/legacy/legal-acceptance.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default function Page() {
8787
// Handle session tasks
8888
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
8989
console.log(session?.currentTask)
90+
return
9091
}
9192

9293
const url = decorateUrl('/')

docs/guides/development/custom-flows/authentication/multi-session-applications.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ To enable multi-session in your application, you need to configure it in the Cle
103103
if (url.startsWith('http')) {
104104
window.location.href = url
105105
} else {
106-
router.push(url)
106+
window.location.href = url
107107
}
108108
},
109109
})

docs/guides/development/custom-flows/authentication/oauth-connections.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,10 @@ You must configure your application instance through the Clerk Dashboard for the
273273
navigate: async ({ session, decorateUrl }) => {
274274
if (session?.currentTask) {
275275
console.log(session?.currentTask)
276+
return
276277
}
277278

278-
const url = decorateUrl('/')
279-
if (url.startsWith('http')) {
280-
window.location.href = url
281-
} else {
282-
router.push(url)
283-
}
279+
router.push(decorateUrl('/'))
284280
},
285281
})
286282
} else {
@@ -519,6 +515,7 @@ With OAuth flows, it's common for users to try to _sign in_ with an OAuth provid
519515
// Handle session tasks
520516
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
521517
console.log(session?.currentTask)
518+
return
522519
}
523520

524521
const url = decorateUrl('/')

docs/guides/development/custom-flows/authentication/session-tasks.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ await setActive({
5454
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
5555
if (session?.currentTask) {
5656
console.log(session?.currentTask)
57+
return
5758
}
5859

5960
const url = decorateUrl('/')

docs/reference/javascript/clerk.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ await clerk.setActive({
11851185
if (url.startsWith('http')) {
11861186
window.location.href = url
11871187
} else {
1188-
router.push(url)
1188+
window.location.href = url
11891189
}
11901190
},
11911191
})

0 commit comments

Comments
 (0)