Skip to content

Commit 127562c

Browse files
cursor[bot]cursoragenttyler-dane
authored
docs(features): align password auth flow with runtime behavior (#1568)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
1 parent 9b3c6fd commit 127562c

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

docs/features/password-auth-flow.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This flow adds first-party auth on top of the existing Google OAuth setup:
99
- sign up with email and password
1010
- sign in with email and password
1111
- forgot/reset password
12-
- account linking so Google and password auth for the same verified email resolve to the same Compass user
12+
- SuperTokens user-to-Compass-user mapping via Mongo `ObjectId` external ids
1313

1414
Primary files:
1515

@@ -29,11 +29,11 @@ Compass still treats the MongoDB `userId` as the canonical identity.
2929

3030
SuperTokens is configured so that:
3131

32-
- Google auth and email/password auth both create or attach to the same primary user when the email can be linked
3332
- password sign-up ensures there is an external user id mapping, and that external id is a Mongo `ObjectId` string
34-
- backend user upserts always write against that canonical Compass user id
33+
- backend user upserts always write against the session user id (`response.session.getUserId()`)
34+
- Google sign-in/up uses `google.googleId` lookup for existing Compass users before creating a new id
3535

36-
The key consequence is that auth method changes should not fork a user into multiple Compass records.
36+
Important constraint: automatic account linking is currently disabled, so matching emails across Google and password auth are **not** auto-merged by middleware configuration.
3737

3838
## Web Entry Points
3939

@@ -162,7 +162,9 @@ Important detail:
162162

163163
That prevents the reset flow from breaking if the URL changes while the modal is open.
164164

165-
On success, the modal returns to the login view.
165+
On success, the modal switches to `loginAfterReset`, which renders the login form and a success status message:
166+
167+
- `"Password reset successful. Log in with your new password."`
166168

167169
## Backend Runtime Flow
168170

@@ -179,11 +181,9 @@ On success, the modal returns to the login view.
179181

180182
`AccountLinking.init()` is configured to:
181183

182-
- decline automatic linking when the new account has no email
183-
- automatically link when an email exists
184-
- require verification before linking
184+
- always return `{ shouldAutomaticallyLink: false }`
185185

186-
That means same-email Google and password accounts should collapse onto one canonical Compass user once SuperTokens has enough verified identity information to link safely.
186+
This means middleware-level automatic linking is disabled for all sign-in/up paths.
187187

188188
### Google sign-in/up
189189

@@ -229,7 +229,7 @@ This is the step that makes the Compass user record line up with the SuperTokens
229229
- updates `lastLoggedInAt`
230230
- creates default priorities only for a new Compass user
231231

232-
For a linked account, this writes to the existing Compass user instead of creating a duplicate record.
232+
For repeated auth on the same session user id, this writes to the existing Compass user instead of creating a duplicate record.
233233

234234
## Reset Password Delivery
235235

@@ -238,6 +238,7 @@ Current behavior in `supertokens.middleware.ts`:
238238
- all environments rewrite the incoming SuperTokens reset link into Compass app URL shape
239239
- `test` environment logs the rewritten link and skips provider delivery
240240
- non-test environments pass the rewritten link to SuperTokens' original email sender (`originalImplementation.sendEmail`)
241+
- if the incoming link has no `token` query param, backend keeps the original link unchanged
241242

242243
The rewritten link shape comes from `buildResetPasswordLink()` and looks like:
243244

@@ -261,3 +262,4 @@ That lets password-auth users use Compass without blocking on Google connectivit
261262

262263
- The rollout gate is not limited to `lastKnownEmail`; any `?auth=` URL currently enables the auth UI.
263264
- Reset password links always target the `/day` route and require a valid `FRONTEND_URL` in backend env.
265+
- With automatic account linking disabled, same-email Google and email/password identities are not merged automatically.

0 commit comments

Comments
 (0)