Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clerk-js): Improve redirects on OAuth callback #1563

Conversation

kostaspt
Copy link
Member

@kostaspt kostaspt commented Aug 8, 2023

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

Description

  • npm test runs as expected.
  • npm run build runs as expected.

Currently, if you try to sign up with a provider that allows unverified accounts, the flow appears to be broken because it asks for the email after the OAuth callback. With this change, it will navigate to the appropriate change when needed.

Before

Kapture.2023-08-08.at.17.47.29.mp4

After

Kapture.2023-08-08.at.18.33.04.mp4

@changeset-bot
Copy link

changeset-bot bot commented Aug 8, 2023

🦋 Changeset detected

Latest commit: fae3436

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch

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

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

@kostaspt kostaspt force-pushed the kostas/usr-248-when-sign-up-with-unverified-email-from-oauth-trigger-psu-redirects branch 2 times, most recently from 349a4cd to de7fbd7 Compare August 9, 2023 12:07
Currently, if you try to sign up with a provider that allows unverified accounts, the flow appears to be broken because it asks for the email after the OAuth callback. With this change, it will navigate to the appropriate change when needed.
@kostaspt kostaspt force-pushed the kostas/usr-248-when-sign-up-with-unverified-email-from-oauth-trigger-psu-redirects branch from de7fbd7 to c596cf9 Compare August 9, 2023 22:03
@kostaspt kostaspt marked this pull request as ready for review August 10, 2023 08:36
Copy link
Contributor

@alex-ntousias alex-ntousias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @kostaspt .
Added a comment to reduce the changes on this PR, so that FE folks can review it easier and spot any important issues.

packages/clerk-js/src/core/clerk.ts Outdated Show resolved Hide resolved
packages/clerk-js/src/core/clerk.ts Outdated Show resolved Hide resolved
packages/clerk-js/src/core/clerk.ts Outdated Show resolved Hide resolved
packages/clerk-js/src/core/clerk.ts Show resolved Hide resolved
/**
* Full URL or path to navigate after requesting phone verification.
*/
verifyPhoneNumberUrl?: string | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Are these required for this fix? Seems like this is a broader API change for our components.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't need these, but for sign-in, using a relative URL won't work.

I want to redirect in these two cases:

  • sign-up/sso-callback -> sign-up/verify-email-address
  • sign-in/sso-callback -> sign-up/verify-email-address

For the first one to work, a relative URL like ../verify-email-address is working as expected, but for the second one, the hash router will be necessary to navigate here.

Or I might be possibly missing something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for explaining. I guess the problem is the the transfer flow from sign in?

We are on the sign-in/ "base" path and we're mounting components in there. Wonder if there's an alternative where we always go through sign-up/ first or we can somehow reuse the signUpUrl. I'll leave this comment open to get feedback from an expert in our javascript repo. 🙏

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello everyone, is there a design document explaining the changes proposed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @nikosdouvlis, there is no design document for this, but there is more information about the goal of this task in the ticket: https://linear.app/clerk/issue/USR-248

Do you have any concerns about these changes?

@kostaspt kostaspt closed this Aug 10, 2023
@kostaspt kostaspt reopened this Aug 10, 2023
Copy link
Contributor

@alex-ntousias alex-ntousias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @kostaspt , thank you for addressing my comments. 🚀

Copy link
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a good example of when we should add an E2E test. (cc @nikosdouvlis)

.changeset/tender-icons-bake.md Show resolved Hide resolved
@kostaspt kostaspt merged commit 4764e40 into main Aug 23, 2023
8 checks passed
@kostaspt kostaspt deleted the kostas/usr-248-when-sign-up-with-unverified-email-from-oauth-trigger-psu-redirects branch August 23, 2023 12:51
@clerk-cookie clerk-cookie mentioned this pull request Aug 23, 2023
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants