You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/password-auth-flow.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ This flow adds first-party auth on top of the existing Google OAuth setup:
9
9
- sign up with email and password
10
10
- sign in with email and password
11
11
- 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
13
13
14
14
Primary files:
15
15
@@ -29,11 +29,11 @@ Compass still treats the MongoDB `userId` as the canonical identity.
29
29
30
30
SuperTokens is configured so that:
31
31
32
-
- Google auth and email/password auth both create or attach to the same primary user when the email can be linked
33
32
- 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
35
35
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.
37
37
38
38
## Web Entry Points
39
39
@@ -162,7 +162,9 @@ Important detail:
162
162
163
163
That prevents the reset flow from breaking if the URL changes while the modal is open.
164
164
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."`
166
168
167
169
## Backend Runtime Flow
168
170
@@ -179,11 +181,9 @@ On success, the modal returns to the login view.
179
181
180
182
`AccountLinking.init()` is configured to:
181
183
182
-
- decline automatic linking when the new account has no email
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.
187
187
188
188
### Google sign-in/up
189
189
@@ -229,7 +229,7 @@ This is the step that makes the Compass user record line up with the SuperTokens
229
229
- updates `lastLoggedInAt`
230
230
- creates default priorities only for a new Compass user
231
231
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.
233
233
234
234
## Reset Password Delivery
235
235
@@ -238,6 +238,7 @@ Current behavior in `supertokens.middleware.ts`:
238
238
- all environments rewrite the incoming SuperTokens reset link into Compass app URL shape
239
239
-`test` environment logs the rewritten link and skips provider delivery
240
240
- 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
241
242
242
243
The rewritten link shape comes from `buildResetPasswordLink()` and looks like:
243
244
@@ -261,3 +262,4 @@ That lets password-auth users use Compass without blocking on Google connectivit
261
262
262
263
- The rollout gate is not limited to `lastKnownEmail`; any `?auth=` URL currently enables the auth UI.
263
264
- 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