fix(auth): retire password reset links when the account's email or password changes

A reset link is a credential sent to the address the account had when it
was asked for. It stayed valid for its full hour after the account moved
to another address or got a new password, so a link sent to the old
mailbox could still set a password on the account.

Changing the email in the user's own settings, changing the password,
and an admin changing a user's email or setting a password now consume
every live reset link of that user, in the same transaction as the
change. Saving the same address, or it in another case, keeps the link,
and a link asked for afterwards works as before.
This commit is contained in:
Maurice
2026-11-26 10:17:13 +01:00
parent 96b2778c2f
commit 4f66a344ca
5 changed files with 152 additions and 4 deletions
@@ -17,6 +17,7 @@ import { resetTestDb } from '../../helpers/test-db';
import {
createTestUnitOfWork,
createTestAppSettingsRepo,
createTestPasswordResetTokensRepo,
createTestUsersRepo,
sharedTestOrm,
} from '../../helpers/test-uow';
@@ -69,6 +70,7 @@ beforeAll(async () => {
await createTestUnitOfWork(testDb),
await createTestAppSettingsRepo(testDb),
await createTestUsersRepo(testDb),
await createTestPasswordResetTokensRepo(testDb),
);
});