Repository navigation
Password change and reset actually work; old sessions end - #38
Merged
Merged
Conversation
The password endpoints were stubs: "Change password" said the password was changed without changing it, and forgot/reset password claimed success while doing nothing. A locked-out user had no way back in. - Change password checks the current password and stores the new one; the response carries new tokens so the current session continues. - Forgot password emails a single-use reset link (30 minutes, newest only) over the SMTP settings from scheduled reports. Same answer whether or not the account exists; the email is sent in the background. Without SMTP it says reset by email is not set up. - Reset password consumes the link once (SECURITY DEFINER function, one statement) and sets the password. - Migration 022: users.password_changed_at (refresh tokens issued earlier are refused, so a change or reset signs out other sessions), password_resets (token hash only), scirm_user_by_id returns the new column, and the two reset functions (granted by db_setup). - Frontend: Settings calls the API; the forgot-password page calls it and shows its answer; new /reset-password page (token in the fragment). - docs/passwords.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Found while preparing SSO. The password endpoints were stubs:
A user who forgot their password had no way back in: admins can't reset passwords, and re-inviting fails because the email already exists.
Now
users.password_changed_atmeans refresh tokens issued before a change or reset are refused. Access tokens already issued last at most 60 minutes.password_changed_atcolumn and thepassword_resetstable (token hash only)scirm_user_by_idrecreated to return the new columndb_setup.py, which the migrate job runs/reset-passwordpage. The token stays in the URL fragment, like invitation links.docs/passwords.md.Testing
tests/security/test_passwords.py:tests/db: the reset functions work with a non-superuser table owner (managed PostgreSQL), and a token works exactly once. Migrations still round-trip.tscclean,vite buildOK. Strict docs build OK.localhost:3000/reset-password#…link → set a new password in the browserauth.password_reset_requestedandauth.password_resetappear in the audit logDeploy note
Migration 022 recreates
scirm_user_by_id. The migrate job re-grants it. Restart the gateway after migrating, as usual.🤖 Generated with Claude Code