Skip to content

Commit c839e4c

Browse files
nikosdouvlisalexisintechmanovotny
authored
Add decorateUrl to navigate callbacks for Safari ITP support (#3037)
Co-authored-by: Alexis Aguilar <98043211+alexisintech@users.noreply.github.com> Co-authored-by: Michael Novotny <manovotny@gmail.com>
1 parent ec328cc commit c839e4c

33 files changed

+432
-137
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default function Page() {
2727

2828
if (signIn.status === 'complete') {
2929
await signIn.finalize({
30-
navigate: () => {
31-
router.push('/')
30+
navigate: ({ decorateUrl }) => {
31+
router.push(decorateUrl('/'))
3232
},
3333
})
3434
}
@@ -44,8 +44,8 @@ export default function Page() {
4444

4545
if (signIn.status === 'complete') {
4646
await signIn.finalize({
47-
navigate: () => {
48-
router.push('/')
47+
navigate: ({ decorateUrl }) => {
48+
router.push(decorateUrl('/'))
4949
},
5050
})
5151
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export default function Page() {
3535

3636
if (signUp.status === 'complete') {
3737
await signUp.finalize({
38-
navigate: () => {
39-
router.push('/')
38+
navigate: ({ decorateUrl }) => {
39+
router.push(decorateUrl('/'))
4040
},
4141
})
4242
}

docs/getting-started/quickstart.mdx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ llm:
1414
link: "https://github.com/clerk/clerk-nextjs-app-quickstart"
1515
}
1616
]}
17-
beforeYouStart={[
18-
{
19-
title: "Set up a Clerk application",
20-
link: "/docs/getting-started/quickstart/setup-clerk",
21-
icon: "clerk",
22-
},
23-
]}
2417
/>
2518

2619
<Steps>

docs/guides/development/custom-flows/account-updates/forgot-password.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,20 @@ This guide demonstrates how to use Clerk's API to build a custom flow for resett
9292
// the newly created session (user is now signed in)
9393
setActive({
9494
session: result.createdSessionId,
95-
navigate: async ({ session }) => {
95+
navigate: async ({ session, decorateUrl }) => {
9696
if (session?.currentTask) {
9797
// Check for tasks and navigate to custom UI to help users resolve them
9898
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
9999
console.log(session?.currentTask)
100100
return
101101
}
102102

103-
router.push('/')
103+
const url = decorateUrl('/')
104+
if (url.startsWith('http')) {
105+
window.location.href = url
106+
} else {
107+
router.push(url)
108+
}
104109
},
105110
})
106111
setError('')
@@ -502,15 +507,20 @@ In this case, you can prompt the user to reset their password using the exact sa
502507
// the newly created session (user is now signed in)
503508
setActive({
504509
session: result.createdSessionId,
505-
navigate: async ({ session }) => {
510+
navigate: async ({ session, decorateUrl }) => {
506511
if (session?.currentTask) {
507512
// Check for tasks and navigate to custom UI to help users resolve them
508513
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
509514
console.log(session?.currentTask)
510515
return
511516
}
512517

513-
router.push('/')
518+
const url = decorateUrl('/')
519+
if (url.startsWith('http')) {
520+
window.location.href = url
521+
} else {
522+
router.push(url)
523+
}
514524
},
515525
})
516526
setError('')

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ To create a sign-up flow using the invitation token, you need to call the [`sign
6060
})
6161
if (signUp.status === 'complete') {
6262
await signUp.finalize({
63-
navigate: () => {
64-
router.push('/')
63+
navigate: ({ decorateUrl }) => {
64+
const url = decorateUrl('/')
65+
if (url.startsWith('http')) {
66+
window.location.href = url
67+
} else {
68+
router.push(url)
69+
}
6570
},
6671
})
6772
}

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ This guide will walk you through how to build a custom email/password sign-in fl
8282
})
8383
if (signIn.status === 'complete') {
8484
await signIn.finalize({
85-
navigate: () => {
86-
router.push('/')
85+
navigate: ({ decorateUrl }) => {
86+
const url = decorateUrl('/')
87+
if (url.startsWith('http')) {
88+
window.location.href = url
89+
} else {
90+
router.push(url)
91+
}
8792
},
8893
})
8994
}
@@ -101,8 +106,13 @@ This guide will walk you through how to build a custom email/password sign-in fl
101106

102107
if (signIn.status === 'complete') {
103108
await signIn.finalize({
104-
navigate: () => {
105-
router.push('/')
109+
navigate: ({ decorateUrl }) => {
110+
const url = decorateUrl('/')
111+
if (url.startsWith('http')) {
112+
window.location.href = url
113+
} else {
114+
router.push(url)
115+
}
106116
},
107117
})
108118
}
@@ -204,8 +214,13 @@ This guide will walk you through how to build a custom email/password sign-in fl
204214

205215
if (signIn.status === 'complete') {
206216
await signIn.finalize({
207-
navigate: () => {
208-
router.push('/')
217+
navigate: ({ decorateUrl }) => {
218+
const url = decorateUrl('/')
219+
if (url.startsWith('http')) {
220+
window.location.href = url
221+
} else {
222+
router.push(url)
223+
}
209224
},
210225
})
211226
}

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ This guide will walk you through how to build a custom email/password sign-up an
7676
})
7777
if (signUp.status === 'complete') {
7878
await signUp.finalize({
79-
navigate: () => {
80-
router.push('/dashboard')
79+
navigate: ({ decorateUrl }) => {
80+
const url = decorateUrl('/dashboard')
81+
if (url.startsWith('http')) {
82+
window.location.href = url
83+
} else {
84+
router.push(url)
85+
}
8186
},
8287
})
8388
}
@@ -395,8 +400,13 @@ This guide will walk you through how to build a custom email/password sign-up an
395400
})
396401
if (signIn.status === 'complete') {
397402
await signIn.finalize({
398-
navigate: () => {
399-
router.push('/')
403+
navigate: ({ decorateUrl }) => {
404+
const url = decorateUrl('/')
405+
if (url.startsWith('http')) {
406+
window.location.href = url
407+
} else {
408+
router.push(url)
409+
}
400410
},
401411
})
402412
}
@@ -414,8 +424,13 @@ This guide will walk you through how to build a custom email/password sign-up an
414424

415425
if (signIn.status === 'complete') {
416426
await signIn.finalize({
417-
navigate: () => {
418-
router.push('/')
427+
navigate: ({ decorateUrl }) => {
428+
const url = decorateUrl('/')
429+
if (url.startsWith('http')) {
430+
window.location.href = url
431+
} else {
432+
router.push(url)
433+
}
419434
},
420435
})
421436
}

docs/guides/development/custom-flows/authentication/email-sms-otp.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ This guide will walk you through how to build a custom SMS OTP sign-up and sign-
7171
await signUp.verifications.verifyPhoneCode({ code })
7272
if (signUp.status === 'complete') {
7373
await signUp.finalize({
74-
navigate: () => {
75-
router.push('/dashboard')
74+
navigate: ({ decorateUrl }) => {
75+
const url = decorateUrl('/dashboard')
76+
if (url.startsWith('http')) {
77+
window.location.href = url
78+
} else {
79+
router.push(url)
80+
}
7681
},
7782
})
7883
}
@@ -388,8 +393,13 @@ This guide will walk you through how to build a custom SMS OTP sign-up and sign-
388393
await signIn.phoneCode.verifyCode({ code })
389394
if (signIn.status === 'complete') {
390395
await signIn.finalize({
391-
navigate: () => {
392-
router.push('/')
396+
navigate: ({ decorateUrl }) => {
397+
const url = decorateUrl('/')
398+
if (url.startsWith('http')) {
399+
window.location.href = url
400+
} else {
401+
router.push(url)
402+
}
393403
},
394404
})
395405
}

docs/guides/development/custom-flows/authentication/embedded-email-links.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,18 @@ This guide will demonstrate how to generate a sign-in token and use it to sign i
8888
// If the sign-in was successful, set the session to active
8989
if (signIn.status === 'complete') {
9090
signIn.finalize({
91-
navigate: async ({ session }) => {
91+
navigate: async ({ session, decorateUrl }) => {
9292
if (session?.currentTask) {
9393
console.log(session?.currentTask)
9494
return
9595
}
9696

97-
router.push('/')
97+
const url = decorateUrl('/')
98+
if (url.startsWith('http')) {
99+
window.location.href = url
100+
} else {
101+
router.push(url)
102+
}
98103
},
99104
})
100105
} else {
@@ -170,13 +175,18 @@ This guide will demonstrate how to generate a sign-in token and use it to sign i
170175
// If the sign-in was successful, set the session to active
171176
if (signIn.status === 'complete') {
172177
signIn.finalize({
173-
navigate: async ({ session }) => {
178+
navigate: async ({ session, decorateUrl }) => {
174179
if (session?.currentTask) {
175180
console.log(session?.currentTask)
176181
return
177182
}
178183

179-
router.push('/')
184+
const url = decorateUrl('/')
185+
if (url.startsWith('http')) {
186+
window.location.href = url
187+
} else {
188+
router.push(url)
189+
}
180190
},
181191
})
182192
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,20 @@ You must configure your application instance through the Clerk Dashboard for the
118118
if (createdSessionId) {
119119
setActive!({
120120
session: createdSessionId,
121-
navigate: async ({ session }) => {
121+
navigate: async ({ session, decorateUrl }) => {
122122
if (session?.currentTask) {
123123
// Check for tasks and navigate to custom UI to help users resolve them
124124
// See https://clerk.com/docs/guides/development/custom-flows/authentication/session-tasks
125125
console.log(session?.currentTask)
126126
return
127127
}
128128

129-
router.push('/')
129+
const url = decorateUrl('/')
130+
if (url.startsWith('http')) {
131+
window.location.href = url
132+
} else {
133+
router.push(url)
134+
}
130135
},
131136
})
132137
} else {

0 commit comments

Comments
 (0)