Max Peintner and GitHub
11912ac749
fix: allow invite codes for users whose auth methods were all removed ( #12453 )
...
# Which Problems Are Solved
When a user has no primary auth method (no password, passkey, or IDP
link), the login app routes them to the verify page and lets them
(re)send an invite code. But clicking **Resend** failed with
`Errors.User.AlreadyInitialised` (surfaced in the login UI as the
misleading "User is already verified!").
The cause was in the invite write model (`UserV2InviteWriteModel`): its
`AuthMethodSet` flag was **sticky**. It was set to `true` the first time
a user ever got a password, passkey, or IDP link, and was never cleared
— the removal events weren't even loaded by the query. So a user who
*once* had an auth method that was later removed was permanently treated
as "initialized," even though `ListUserAuthMethodTypes` (what the login
app checks) correctly reported zero methods. That disagreement blocked
invite creation/resend for legitimately method-less users.
# How the Problems Are Solved
Track the user's auth methods as the **current set** instead of a sticky
flag:
- Replaced the `AuthMethodSet bool` field with an `authMethods` set,
keyed uniquely per method (password / IDP link / passkey).
- Reduce now also handles the removal events (`UserIDPLinkRemoved`,
`UserIDPLinkCascadeRemoved`, `HumanPasswordlessTokenRemoved`), and these
event types were added to the write model's query filter so they're
loaded.
- `AuthMethodSet()` is now simply "does the user currently have ≥1 auth
method," so `CreationAllowed()` reflects reality.
The security guard is unchanged: a user who still has any auth method is
refused. The only behavior change is that a user with **no current**
auth method (including one whose methods were all removed) can again
receive an invite code — matching what the login app already assumes. No
extra queries (same single event filter, a few more event types), and no
data migration (pure re-derivation from existing events).
Added tests covering both an initialized user (still refused) and invite
creation succeeding after all auth methods are removed.
2026-08-12 06:24:28 +00:00
..
2025-01-29 10:29:00 +00:00
2023-12-08 15:30:55 +01:00
2024-05-04 11:55:57 +02:00
2024-07-31 14:42:12 +02:00
2025-12-29 13:35:53 +00:00
2024-07-31 14:42:12 +02:00
2025-12-29 13:35:53 +00:00
2025-12-29 13:35:53 +00:00
2025-12-29 13:35:53 +00:00
2025-12-29 13:35:53 +00:00
2025-12-29 13:35:53 +00:00
2026-06-15 15:36:14 +02:00
2026-06-15 15:36:14 +02:00
2023-12-08 15:30:55 +01:00
2026-03-17 12:54:27 +01:00
2026-03-17 12:54:27 +01:00
2026-03-17 12:54:27 +01:00
2024-11-04 10:44:51 +00:00
2026-02-13 13:06:56 +00:00
2026-07-29 05:46:27 +02:00
2025-02-26 16:06:50 +00:00
2026-06-05 14:48:35 +02:00
2024-09-26 09:14:33 +02:00
2024-08-28 05:33:20 +00:00
2024-08-28 05:33:20 +00:00
2022-12-01 13:31:46 +01:00
2024-09-11 08:24:00 +00:00
2024-09-11 08:24:00 +00:00
2024-09-11 08:24:00 +00:00
2022-04-26 23:01:45 +00:00
2026-03-17 12:54:27 +01:00
2026-06-16 16:52:26 +02:00
2026-06-16 15:19:56 +02:00
2024-09-11 10:53:55 +00:00
2022-04-26 23:01:45 +00:00
2026-06-15 11:24:37 +02:00
2025-10-21 11:18:21 +02:00
2025-10-28 13:23:54 +00:00
2025-10-28 13:23:54 +00:00
2025-10-28 13:23:54 +00:00
2025-06-18 13:24:39 +02:00
2025-06-18 13:24:39 +02:00
2025-06-18 13:24:39 +02:00
2022-04-26 23:01:45 +00:00
2022-10-17 19:19:15 +00:00
2026-02-19 06:06:30 +00:00
2026-06-11 19:52:11 +02:00
2026-06-15 15:36:14 +02:00
2026-07-17 13:24:18 +02:00
2026-07-17 13:24:18 +02:00
2026-06-15 15:27:47 +02:00
2024-05-13 16:01:50 +02:00
2024-04-03 10:43:43 +00:00
2024-08-28 05:33:20 +00:00
2026-02-10 20:25:39 +01:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2024-06-17 12:47:38 +00:00
2023-10-19 12:19:10 +02:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2023-10-19 12:19:10 +02:00
2024-11-22 17:25:28 +01:00
2026-02-10 20:25:39 +01:00
2023-10-19 15:21:31 +00:00
2026-08-12 08:04:27 +02:00
2026-01-26 14:52:15 +00:00
2026-02-27 09:43:11 +01:00
2026-02-27 09:43:11 +01:00
2026-02-02 09:47:56 +00:00
2026-03-30 15:59:57 +00:00
2024-04-03 10:43:43 +00:00
2023-12-08 15:30:55 +01:00
2026-02-10 20:25:39 +01:00
2024-04-03 10:43:43 +00:00
2023-12-08 15:30:55 +01:00
2026-02-10 20:25:39 +01:00
2026-07-13 09:22:31 +02:00
2024-04-05 09:35:49 +00:00
2023-12-08 15:30:55 +01:00
2026-02-10 20:25:39 +01:00
2026-07-10 09:17:49 +02:00
2026-07-06 10:18:35 +02:00
2025-07-04 18:12:59 +02:00
2026-07-28 15:20:46 +02:00
2026-07-28 15:20:46 +02:00
2024-04-11 09:16:10 +02:00
2022-04-26 23:01:45 +00:00
2024-08-12 22:32:01 +02:00
2023-12-08 15:30:55 +01:00
2026-02-10 20:25:39 +01:00
2025-09-08 13:58:14 +00:00
2026-02-10 20:25:39 +01:00
2023-10-26 05:54:09 +00:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2022-04-26 23:01:45 +00:00
2023-10-19 12:19:10 +02:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2024-04-03 10:43:43 +00:00
2024-04-03 10:43:43 +00:00
2026-02-10 20:25:39 +01:00
2023-01-25 09:49:41 +01:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2024-04-10 09:14:55 +00:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2024-05-13 16:01:50 +02:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2026-07-30 14:43:47 +00:00
2026-07-30 14:43:47 +00:00
2025-02-26 16:06:50 +00:00
2025-02-26 16:06:50 +00:00
2025-04-02 16:53:06 +02:00
2023-10-19 12:19:10 +02:00
2026-07-01 04:53:16 +00:00
2026-07-01 04:53:16 +00:00
2026-01-27 15:11:56 +01:00
2026-08-12 08:04:27 +02:00
2025-12-17 12:01:09 +01:00
2026-02-23 06:06:33 +00:00
2024-07-31 18:00:38 +03:00
2026-07-01 04:53:16 +00:00
2022-04-26 23:01:45 +00:00
2024-08-14 14:18:14 +00:00
2025-06-26 19:17:45 +03:00
2024-01-17 10:16:48 +00:00
2024-01-17 10:16:48 +00:00
2024-08-12 22:32:01 +02:00
2024-01-17 10:16:48 +00:00
2024-10-31 15:57:17 +01:00
2024-10-31 15:57:17 +01:00
2026-07-30 14:43:47 +00:00
2022-04-26 23:01:45 +00:00
2026-06-15 11:24:37 +02:00
2024-10-28 08:29:34 +00:00
2026-01-26 14:52:15 +00:00
2026-01-26 14:52:15 +00:00
2026-04-08 08:48:05 +02:00
2022-04-26 23:01:45 +00:00
2024-05-16 07:07:56 +02:00
2026-06-16 15:19:56 +02:00
2026-06-16 15:19:56 +02:00
2026-06-15 11:24:37 +02:00
2024-08-12 22:32:01 +02:00
2024-06-19 12:56:33 +02:00
2024-05-13 16:01:50 +02:00
2022-04-26 23:01:45 +00:00
2024-08-28 05:33:20 +00:00
2024-06-19 12:56:33 +02:00
2022-04-26 23:01:45 +00:00
2026-03-03 10:24:44 +00:00
2024-06-19 12:56:33 +02:00
2026-06-15 11:24:37 +02:00
2026-03-31 09:58:42 +02:00
2026-03-31 09:58:42 +02:00
2022-04-26 23:01:45 +00:00
2024-08-12 22:32:01 +02:00
2024-11-14 14:04:39 +00:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2024-06-19 12:56:33 +02:00
2024-04-03 10:43:43 +00:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2026-07-13 09:22:31 +02:00
2024-04-05 09:35:49 +00:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2026-07-28 15:20:46 +02:00
2026-07-28 15:20:46 +02:00
2022-04-26 23:01:45 +00:00
2025-07-04 18:12:59 +02:00
2026-02-10 20:25:39 +01:00
2026-06-15 11:24:37 +02:00
2026-03-10 10:09:51 +00:00
2026-03-10 10:09:51 +00:00
2025-07-04 18:12:59 +02:00
2023-12-08 15:30:55 +01:00
2025-07-29 15:56:21 +02:00
2025-07-29 15:56:21 +02:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2026-02-10 20:25:39 +01:00
2024-04-10 09:14:55 +00:00
2024-04-10 09:14:55 +00:00
2024-06-19 12:56:33 +02:00
2022-11-30 17:01:17 +01:00
2022-04-26 23:01:45 +00:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2024-06-19 12:56:33 +02:00
2024-04-03 10:43:43 +00:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2023-01-25 09:49:41 +01:00
2024-08-12 22:32:01 +02:00
2023-12-08 15:30:55 +01:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2023-12-08 15:30:55 +01:00
2024-04-03 10:43:43 +00:00
2024-08-12 22:32:01 +02:00
2024-06-19 12:56:33 +02:00
2024-05-13 16:01:50 +02:00
2024-08-12 22:32:01 +02:00
2024-06-19 12:56:33 +02:00
2026-04-13 10:59:50 +00:00
2026-04-13 10:59:50 +00:00
2025-07-29 15:56:21 +02:00
2025-07-29 15:56:21 +02:00
2025-07-29 15:56:21 +02:00
2025-09-16 12:26:21 +00:00
2026-07-30 14:43:47 +00:00
2023-12-08 15:30:55 +01:00
2025-01-27 13:36:07 +01:00
2023-10-26 05:54:09 +00:00
2022-04-26 23:01:45 +00:00
2023-07-20 04:06:16 +00:00
2022-04-26 23:01:45 +00:00
2023-01-25 09:49:41 +01:00
2025-07-29 15:56:21 +02:00
2022-04-26 23:01:45 +00:00
2023-12-08 15:30:55 +01:00
2024-04-10 09:14:55 +00:00
2024-05-13 16:01:50 +02:00
2024-08-12 22:32:01 +02:00
2026-06-15 11:24:37 +02:00
2025-06-27 17:25:44 +02:00
2025-10-17 10:12:20 +02:00
2026-06-15 11:24:37 +02:00
2025-07-02 07:34:19 +00:00
2025-07-02 07:34:19 +00:00
2026-06-15 11:24:37 +02:00
2026-08-12 08:04:27 +02:00
2026-08-03 08:37:59 +00:00
2026-08-12 08:04:27 +02:00
2026-08-12 08:04:27 +02:00
2026-08-12 08:04:27 +02:00
2026-08-12 08:04:27 +02:00
2026-06-15 11:24:37 +02:00
2025-06-27 17:25:44 +02:00
2025-06-27 17:25:44 +02:00
2026-06-15 11:24:37 +02:00
2026-08-12 08:04:27 +02:00
2025-10-17 10:12:20 +02:00
2025-06-27 17:25:44 +02:00
2025-06-27 17:25:44 +02:00
2026-08-12 08:04:27 +02:00
2026-06-15 11:24:37 +02:00
2025-09-21 14:04:25 +00:00
2026-03-03 10:24:44 +00:00
2026-06-15 11:24:37 +02:00
2025-09-21 14:04:25 +00:00
2025-09-21 14:04:25 +00:00
2025-01-17 16:16:26 +01:00
2025-07-04 18:12:59 +02:00
2025-07-04 18:12:59 +02:00
2026-06-15 11:24:37 +02:00
2025-06-04 11:46:10 +00:00
2026-06-15 11:24:37 +02:00
2025-05-21 14:40:47 +02:00
2026-07-09 13:28:09 +02:00
2025-05-21 14:40:47 +02:00
2025-08-15 11:35:43 +02:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2023-10-19 12:19:10 +02:00
2023-09-15 16:58:45 +02:00
2024-08-12 22:32:01 +02:00
2023-12-08 15:30:55 +01:00
2025-06-04 07:17:23 +00:00
2023-12-05 11:12:01 +00:00
2024-08-12 22:32:01 +02:00
2024-04-08 08:15:44 +00:00
2025-03-26 17:08:13 +00:00
2025-07-15 13:38:00 +02:00
2025-07-15 13:38:00 +02:00
2024-12-19 11:11:40 +00:00
2025-07-15 16:03:47 +00:00
2025-07-15 16:03:47 +00:00
2025-11-24 06:44:48 +00:00
2025-11-24 06:44:48 +00:00
2025-10-29 10:07:35 +01:00
2025-10-29 10:07:35 +01:00
2025-11-24 06:44:48 +00:00
2026-06-15 11:24:37 +02:00
2026-03-27 12:38:40 +01:00
2023-12-08 15:30:55 +01:00
2026-04-13 10:59:50 +00:00
2025-09-08 11:00:04 +00:00
2026-06-15 15:36:14 +02:00
2026-06-15 15:36:14 +02:00
2026-06-15 15:36:14 +02:00
2026-06-15 15:36:14 +02:00
2025-03-24 06:03:24 +00:00
2026-02-05 10:51:09 +00:00
2026-02-05 10:51:09 +00:00
2026-02-05 10:51:09 +00:00
2026-01-26 14:52:15 +00:00
2024-01-02 14:26:31 +00:00
2026-03-11 08:25:21 +01:00
2023-12-08 15:30:55 +01:00
2024-06-19 12:56:33 +02:00
2022-04-26 23:01:45 +00:00
2026-06-15 11:24:37 +02:00
2026-07-09 13:28:09 +02:00
2026-07-09 13:28:09 +02:00
2026-06-15 11:24:37 +02:00
2026-06-15 11:24:37 +02:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2024-08-12 22:32:01 +02:00
2023-12-08 15:30:55 +01:00
2026-06-15 11:24:37 +02:00
2026-02-13 13:06:56 +00:00
2026-02-13 13:06:56 +00:00
2026-06-15 11:24:37 +02:00
2024-08-12 22:32:01 +02:00
2024-05-02 11:50:13 +02:00
2026-06-15 11:24:37 +02:00
2026-06-15 11:24:37 +02:00
2025-10-29 10:07:35 +01:00
2025-10-29 10:07:35 +01:00
2026-06-15 11:24:37 +02:00
2025-10-29 10:07:35 +01:00
2026-06-05 14:48:35 +02:00
2026-06-15 11:24:37 +02:00
2024-09-26 09:14:33 +02:00
2024-09-26 09:14:33 +02:00
2026-06-15 11:24:37 +02:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2026-06-15 11:24:37 +02:00
2026-06-15 11:24:37 +02:00
2026-02-26 19:22:37 +01:00
2026-02-26 19:22:37 +01:00
2026-06-15 11:24:37 +02:00
2024-08-12 22:32:01 +02:00
2024-05-16 07:07:56 +02:00
2026-06-05 14:48:35 +02:00
2026-06-15 11:24:37 +02:00
2026-03-11 08:25:21 +01:00
2026-03-27 12:38:40 +01:00
2026-06-05 14:48:35 +02:00
2026-06-15 11:24:37 +02:00
2024-08-14 13:04:26 +00:00
2025-07-04 18:12:59 +02:00
2026-06-15 11:24:37 +02:00
2024-08-12 22:32:01 +02:00
2025-06-04 07:17:23 +00:00
2026-06-15 11:24:37 +02:00
2025-08-19 15:22:34 +02:00
2025-08-19 15:22:34 +02:00
2026-03-16 13:12:21 +01:00
2026-03-16 13:12:21 +01:00
2022-07-06 14:09:49 +02:00
2026-06-15 11:24:37 +02:00
2026-03-09 10:47:32 +01:00
2026-03-10 10:09:51 +00:00
2026-06-15 11:24:37 +02:00
2023-12-08 15:30:55 +01:00
2023-12-08 15:30:55 +01:00
2024-04-03 10:43:43 +00:00
2026-04-13 10:59:50 +00:00
2026-04-13 10:59:50 +00:00
2025-03-25 07:01:29 +00:00
2024-08-28 19:46:45 +00:00
2024-09-17 08:27:48 +00:00
2025-10-28 13:23:54 +00:00
2026-06-08 16:41:08 +02:00
2026-06-08 16:41:08 +02:00
2026-06-08 16:41:08 +02:00
2026-06-08 16:41:08 +02:00
2026-08-12 06:24:28 +00:00
2026-08-12 06:24:28 +00:00
2026-02-20 12:34:07 +00:00
2026-03-09 10:47:32 +01:00
2026-03-09 10:47:32 +01:00
2026-06-15 11:24:37 +02:00
2026-06-15 11:24:37 +02:00
2026-03-11 08:25:21 +01:00
2026-03-11 08:25:21 +01:00
2026-02-13 13:06:56 +00:00
2026-02-13 13:06:56 +00:00
2026-06-08 16:41:08 +02:00
2026-06-08 16:41:08 +02:00
2025-10-28 13:23:54 +00:00
2024-05-14 09:20:31 +02:00
2024-05-07 05:38:26 +00:00
2024-07-31 18:00:38 +03:00
2024-05-07 05:38:26 +00:00
2025-07-29 15:56:21 +02:00
2025-10-28 13:23:54 +00:00
2024-09-25 13:31:31 +00:00
2024-09-25 13:31:31 +00:00
2024-09-26 09:14:33 +02:00
2024-09-26 09:14:33 +02:00
2024-09-26 09:14:33 +02:00
2024-09-26 09:14:33 +02:00
2024-09-26 09:14:33 +02:00
2026-02-13 13:06:56 +00:00
2024-08-14 14:18:14 +00:00
2025-04-02 16:53:06 +02:00
2025-04-02 16:53:06 +02:00