feat: DAH-4244 Detect if account exists - #3041
Open
jimlin-sfgov wants to merge 10 commits into
Open
Conversation
alulabeshue-sfgov
temporarily deployed
to
dahlia-webap-dah-4244-s-ztmz8b
August 22, 2026 00:00
Inactive
jimlin-sfgov
marked this pull request as ready for review
August 25, 2026 19:43
Contributor
There was a problem hiding this comment.
Pull request overview
This PR upgrades the Clerk React SDK and updates the account creation/sign-in flows to detect whether an email already has an account, transferring users into the appropriate Clerk flow (sign-in vs sign-up) and updating related tests/mocks accordingly.
Changes:
- Replace
@clerk/clerk-reactwith@clerk/react(dependency + imports) and update Clerk hook usage to the v6 resource APIs. - Add “transfer” behavior between sign-up and sign-in code flows based on Clerk error/status responses (account-exists detection and sign-up-if-missing transfer).
- Update Jest mocks and tests to reflect the new Clerk resource methods (
emailCode.*,finalize,fetchStatus, etc.).
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Updates lockfile for @clerk/react and transitive dependency changes. |
| package.json | Switches dependency from @clerk/clerk-react to @clerk/react. |
| app/javascript/pages/account/verification-code.tsx | Migrates verification/resend logic to new Clerk APIs; adds sign-in↔sign-up transfer handling. |
| app/javascript/pages/account/create-an-account.tsx | Detects existing accounts and transfers create-account into sign-in code flow when applicable. |
| app/javascript/pages/account/add-password.tsx | Updates Clerk import to @clerk/react. |
| app/javascript/pages/account/account.tsx | Updates Clerk import to @clerk/react. |
| app/javascript/layouts/withAppSetup.tsx | Updates ClerkProvider import to @clerk/react. |
| app/javascript/layouts/Layout.tsx | Updates Clerk import to @clerk/react. |
| app/javascript/layouts/AccountNav.tsx | Updates Clerk import to @clerk/react. |
| app/javascript/hooks/useFeatureFlag.tsx | Minor formatting-only change. |
| app/javascript/authentication/withAuthentication.tsx | Updates Clerk import to @clerk/react. |
| app/javascript/authentication/SignInFlow.tsx | Migrates sign-in flows to new Clerk APIs (create, emailCode.sendCode, finalize, fetchStatus). |
| app/javascript/tests/setupTests.ts | Updates global Clerk mocks to @clerk/react. |
| app/javascript/tests/pages/SignInFlow.test.tsx | Updates tests/mocks to new Clerk resource APIs and code-flow behavior. |
| app/javascript/tests/pages/account/verification-code.test.tsx | Updates tests/mocks for verification/resend/finalize and transfer-to-sign-up behavior. |
| app/javascript/tests/pages/account/create-an-account.test.tsx | Adds coverage for transfer-to-sign-in behavior when account exists; updates mocks. |
| app/javascript/tests/pages/account/add-password.test.tsx | Updates Clerk mocks to @clerk/react. |
| app/javascript/tests/util/accountUtils.tsx | Updates Clerk import to @clerk/react. |
Suppressed comments (1)
app/javascript/pages/account/verification-code.tsx:100
verifySignUpCodeignores the result ofsignUp.emailCode.verifyCode(...). If Clerk returns an{ error }object (as with the sign-in verify path), an invalid code may not be handled consistently and the only signal becomes a non-completestatus. Capture and handle the error explicitly so invalid codes reliably surface the form error state and log the right details.
const verifySignUpCode = async (code: string) => {
if (signUpStatus === "fetching" || !signUp) return
await signUp.emailCode.verifyCode({ code })
if (signUp.status === "complete") {
await signUp.finalize({
navigate: ({ decorateUrl }: { decorateUrl: (url: string) => string }) => {
void navigate(decorateUrl(getAddPasswordPath()))
},
})
} else {
console.error("Code verification error:", signUp)
setError("code", { message: "invalid" })
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jimlin-sfgov
force-pushed
the
DAH-4244-sign-up-if-missing
branch
from
August 25, 2026 21:44
9aeb039 to
2660b6e
Compare
jimlin-sfgov
requested review from
a team,
alulabeshue-sfgov and
cliu02
and removed request for
a team
August 25, 2026 23:13
jimlin-sfgov
force-pushed
the
DAH-4244-sign-up-if-missing
branch
from
August 26, 2026 00:28
7717481 to
5eb2bfb
Compare
jimlin-sfgov
force-pushed
the
DAH-4244-sign-up-if-missing
branch
from
August 26, 2026 18:34
5eb2bfb to
705f0e1
Compare
jimlin-sfgov
force-pushed
the
DAH-4244-sign-up-if-missing
branch
from
August 26, 2026 21:41
705f0e1 to
1bf46ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
New sign-in/sign-up behavior:
A big portion of the diff is updating to the latest Clerk SDK, and resolving conflicts that came from the update.
If you are running this PR locally, you must update your node packages.
Jira ticket
https://sfgovdt.jira.com/browse/DAH-4244
Before requesting eng review
Version Control
angularif it contains updates to Angular codetype: TICKET-NUMBER Descriptionformat, useDAH-000if it does not need a ticketurgent: Descriptionformat if it is urgent and does not need a ticketCode quality
Code conventions
.scssstylesheets andui-seedstokens, rather than inline styles or TailwindReview instructions
Request eng review
needs reviewlabelHousing Enggroup to automatically assign reviewers, and/or assign specific engineersBefore merging
Request product acceptance (PA) testing
needs product acceptancelabel)