Repository navigation
feat(mosaic): redeem invitations in sign-up - #10944
austincalvelage merged 25 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 8b31bf6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
c977252 to
c0fd345
Compare
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-biometrics
@clerk/expo-google-signin
@clerk/expo-native-components
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/mosaic
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
8f5cd12 to
a36f82f
Compare
a36f82f to
d487ad9
Compare
d487ad9 to
bd8e06a
Compare
2c3f167 to
ec7bc61
Compare
Sign-up redeems a ticket from __clerk_ticket or __clerk_invitation_token once, showing the loading screen, then goes to the step the sign-up needs, usually continue for the password. A rejected ticket shows its error on the start form, which then works as a normal sign-up. While the invitation's sign-up is in progress, the start form locks the invited email and updates that sign-up instead of creating a new one.
…ith FAPI's real codes
…icted mode A sign-up is the invitation's when FAPI verified its email with the ticket strategy, so an earlier sign-up on the client no longer blocks redemption or poses as the invitation. With a ticket in the URL, start shows the form in restricted and waitlist mode. Submitting the start form clears a rejected invitation's error, and Start over removes the ticket parameters.
…t is in the URL An abandoned invitation sign-up stayed on the client, so a later visit to the plain sign-up page locked the start form to the invited email and updated the old sign-up. Sign-up now also needs the ticket in the URL, as legacy `SignUpStart` does with `hasExistingSignUpWithTicket`.
The invitation checks pushed `useSignUpModel` past the cognitive complexity limit. The channels an invitation hides are picked once at the top.
Folds the rejected and expired invitation tests into one table.
…tion is blocked Fails today. The blocked notice now comes from the result a request resolves with, and redeeming an invitation still rejects with the error, so the start form shows it inline.
…ion is blocked `redeemTicket` resolves with the blocked result when FAPI answers `action_blocked`, as `create` and the Protect proof do, and the controller keeps it for the mount. Any other error still rejects and shows on the start form.
…finishes signing up An invitation that leaves nothing to fill in completes on redemption. The first test holds the session activation and fails today: the start form shows, locked and busy, between the loading screen and the navigation. It also pins that the invitation is redeemed once on this path. The second test passes today. It pins what a failed activation shows: the error on the start form, with the way to sign in.
…inishes signing up An invitation that leaves nothing to fill in completes on redemption. The loading screen showed only while the ticket action was pending, and that action ends as soon as it hands the step to the finish machine. The finish froze the model, which says start, so the start form showed, locked and busy, until the session was active. The ticket action now hands next the loading screen, and the finish freezes it with the model. A failed activation ends the hold, so start shows the error.
The invitation tests move out of the shared sign-up feature test with the helpers they alone use, and are grouped by what the invitee is doing in place of one "SignUp invitations" block.
…hine's arrival state The controller records why the visitor arrived, and a ticket arrival starts the activity machine in redeemingTicket, whose invoke redeems once. This replaces the ticket's pending-action key, its run-once ref and the effect that ran it. FINALIZE sent while redeeming freezes the loading screen, so next no longer hands the screen over.
…ed notice when one is rejected Sign-up told an invitation's sign-up by its ticket email verification, so an unfinished invitation stopped the next ticket from being redeemed. A rejected ticket only left the URL, which rerenders nothing, so restricted mode kept the form. The SignUp wrapper now holds the ticket in state, sign-up redeems it on every visit to start, and the controller forgets it when FAPI rejects it.
…r invitation started With a ticket held and no sign-up on the client, start created a sign-up without the ticket, so a restricted or waitlist instance refused it and a public one left the invitation pending. The create now carries the ticket, and the fake FAPI gives a ticket sign-up the invitation's email whatever address is sent, as FAPI does. The start form also keeps the invited email locked and offers no alternative phone channel after the reset, because both now follow the held ticket and the email the form holds, not the sign-up.
A visitor who opened sign-up from an invitation link while signed in, in single-session mode, or with a session task pending, still had the ticket redeemed: the arrival intent was picked from the route alone, so the machine started in redeemingTicket while the same render hid the flow and left. The redemption could create and activate a new session behind the redirect. The intent now reads the arrival session override and redeems only when it is none, as ui's withRedirectToAfterSignUp and withRedirectToSignUpTask keep SignUpStart from mounting.
| }, | ||
| forgetTicket, | ||
| finalize: async () => { | ||
| forgetTicket(); |
There was a problem hiding this comment.
In restricted or waitlist mode, when an invitation completes on redemption and finalize() fails, the user sees the "Access restricted" notice instead of the start form. forgetTicket() here runs before finalize(), so screenFor (sign-up.controller.ts:149) has no attempt.ticket and returns signUpMode. docs/internals/sign-in-sign-up-flow.md:124 says this case should land on "a normal sign-up form with its sign-in link".
Reproduced with a restricted-mode copy of "shows why on the start form, with the way to sign in, when the new session cannot be activated" (same tkt_complete seed, mode: 'restricted', touch request failed). It fails on 03e119b: expected <h2>Access restricted</h2> to be null. The error alert does show, but on the restricted notice.
One fix is to keep the start form after a failed finalize that began with a ticket. Another is to update the doc if the restricted notice is what you want. Either way, the restricted-mode test should go in with it.
There was a problem hiding this comment.
ui lands on the restricted notice here too: completeSignUpFlow removes __clerk_ticket before setActive, and SignUpStart's catch clears the form's ticket, so SignUpStart.tsx:395 renders SignUpRestrictedAccess. I kept that and fixed the doc instead, in 8b31bf6, which says start shows what a visit without an invitation does: the form on a public instance and the restricted or waitlist notice with the error otherwise. Your restricted-mode test is in the same commit, along with a waitlist case.
…icted notice outside public mode
Description
Redeems invitations in Mosaic sign-up. Stacked on #10930.
When someone opens an invitation link, sign-up redeems the ticket, shows the loading screen while it does, and goes to the step the sign-up still needs. That is usually the continue screen for a password, since the invitation already verified the email.
Shared changes (for Mosaic reviewers)
ticket_invalid_codeorticket_expired_code.1. Sign-up holds the ticket and the model redeems it.
SignUpreads__clerk_ticketor__clerk_invitation_tokenonce, when it mounts, as legacy's start card does, and passes it to the model.redeemTicketreturns the next step, or the blocked notice when FAPI blocks the request, and the invited email for the form. When FAPI rejects the ticket, the controller forgets it before the failure renders, so a rejected ticket leaves a normal start form.2. Sign-up redeems the ticket on each visit to
start. As in legacy, a reload redeems again, which FAPI accepts until the sign-up completes. A second invitation opened in the same browser therefore replaces an unfinished one. A sign-up is the invitation's while a ticket is held and a sign-up exists, the same rule as legacy'shasExistingSignUpWithTicket. The screen isloadingwhile it runs. A rejected ticket shows its error on the start form until the user submits it.3. Going back to
startnever drops the invitation. While the invitation's sign-up is in progress,startlocks the invited email and updates that sign-up instead of creating a new one. WhatsApp is hidden, as in legacy. With a ticket in the URL,startshows the form in restricted and waitlist mode, because FAPI lets a ticket through. The rule follows the held ticket, as legacy's does: if the app resets the sign-up while the ticket is held,startkeeps the invited email locked, hides WhatsApp, and creates the new sign-up with the ticket.4. The invitation's sign-up finishes on the continue screen. It sends the password with the update, as #10881 already does for any sign-up. An invitation that FAPI completes on redemption keeps the loading screen up until sign-up leaves.
Finishing or starting over removes the ticket parameters from the URL.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
🤖 Generated with Claude Code