Files
romm/backend/handler/auth
Georges-Antoine Assi ff9627ae70 fix(auth): require the current password to change your own username, password or email (#5351)
* feat(auth): require the current password to change your own password

PUT /api/users/{id} set a new password or email for the caller with
nothing more than a me.write credential, so a leaked client token or a
hijacked session could take the account over for good.

A self-edit that changes the password or the email now needs
current_password, checked with bcrypt off the event loop (400 when
missing, 403 when wrong). Admins editing another user and the
forgot/reset-password flow are unchanged. Accounts with no local
password (OIDC-provisioned placeholders) can set a first one only from a
sign-in session, not from a bearer or client token.

UserSchema gains has_password so the UI asks for the current password
only when the backend will: the change-password dialog, the profile
email field, and the edit-user dialog when editing yourself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(user): shorten _verify_account_holder docstring

Addresses Greptile review on #5351.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(user): treat a case-only email edit as no change (code-review)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor(user): simplify current-password checks and tests (simplify)

Hash the new password off the event loop, reuse errorMessage and the
viewer token fixture, and table-drive the needsCurrentPassword tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(user): require the current password to change your own username

Login is by username and a rename revokes every session, so a stolen
me.write token could lock the owner out without touching the password.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(user): lock the email of OIDC accounts to the identity provider

The provider overwrites a linked account's email at every sign-in, and
finds an unlinked password-less account by it, so a self-edit is either
lost or breaks SSO sign-in. Admins can still change it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(RTextField): give read-only fields a muted style

Dashed chrome, no fill and muted text, with no hover or pointer-focus
halo, so a locked value no longer looks editable. Keyboard and gamepad
focus keep their outline.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-26 11:12:27 -04:00
..