fix(clerk-js): Fix FAPI initiated redirect flow for OAuth2 IDP flow with email_link verification#2677
Conversation
🦋 Changeset detectedLatest commit: 575478b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
panteliselef
left a comment
There was a problem hiding this comment.
@mzhong9723 Seems like this was reported for v4 components and we should probably need to backport this PR to v4.
I will help with that once the PR is merged to main. Could we just add a description in the changeset ?
| --- | ||
| --- |
There was a problem hiding this comment.
Maybe something like this ?
| --- | |
| --- | |
| --- | |
| '@clerk/clerk-js': patch | |
| --- | |
| Fix redirect flow for OAuth2 IDP flow with email_link verification. |
| @@ -1615,9 +1615,11 @@ export class Clerk implements ClerkInterface { | |||
| const userSignedIn = this.session; | |||
| const signInUrl = this.#environment?.displayConfig.signInUrl; | |||
There was a problem hiding this comment.
In ClerkJS both signInUrl and signUpUrl can be injected via ClerkOptions. These ClerkOptions come from CLERK_SIGN_IN_URL in frameworks such as Next.js. The display config settings are left as a fallback and are downplayed in v5.
So for this method, we should pick signInUrl and signUpUrl from ClerkOptions first.
There was a problem hiding this comment.
@SokratisVidros updated both sign in and sign up urls to use ClerkOptions first and display config urls as a second fallback option
37851d3 to
6574d50
Compare
6574d50 to
f5e6a4f
Compare
|
|
||
| const userSignedIn = this.session; | ||
| const signInUrl = this.#environment?.displayConfig.signInUrl; | ||
| const signInUrl = this.#options.signInUrl ? this.#options.signInUrl : this.#environment?.displayConfig.signInUrl; |
There was a problem hiding this comment.
| const signInUrl = this.#options.signInUrl ? this.#options.signInUrl : this.#environment?.displayConfig.signInUrl; | |
| const signInUrl = this.#options.signInUrl || this.#environment?.displayConfig.signInUrl; |
…ith email_link verification For the OAuth2 IDP flow, we should not redirect when the referrer is the sign up url. This way, the second factor can be completed after a first factor like email verification link. Previously, users were being redirected back to FAPI /oauth/authorize prematurely. This change ensures that users will not be redirected as such and have the chance to complete their second factor verification, like phone code.
f5e6a4f to
575478b
Compare
…ith email_link verification (#2677) For the OAuth2 IDP flow, we should not redirect when the referrer is the sign up url. This way, the second factor can be completed after a first factor like email verification link. Previously, users were being redirected back to FAPI /oauth/authorize prematurely. This change ensures that users will not be redirected as such and have the chance to complete their second factor verification, like phone code. (cherry picked from commit 7503376)
…ith email_link verification (#2677) (#2702) For the OAuth2 IDP flow, we should not redirect when the referrer is the sign up url. This way, the second factor can be completed after a first factor like email verification link. Previously, users were being redirected back to FAPI /oauth/authorize prematurely. This change ensures that users will not be redirected as such and have the chance to complete their second factor verification, like phone code. (cherry picked from commit 7503376) Co-authored-by: Mary Zhong <mary@clerk.dev>
Description
For the OAuth2 IDP flow, we should not redirect when the referrer is the sign up url. This way, a second factor can be completed after a first factor like email verification link. Previously, users were being redirected back to
FAPI /oauth/authorizeprematurely. This change ensures that users will not be redirected as such and have the chance to complete their second factor verification, like phone code.Fixes CORE-1567
Video of fix below (there's a jump in the middle because I cut out retrieving the email link from my inbox):
https://github.com/clerk/javascript/assets/27433835/63e4ec43-1107-4c90-8ee5-f9196be7210c
Previously, the user would be redirected back to the sign in page without being able to complete sign up.
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore