Skip to content

feat: require current password when changing password (#3120)#3980

Open
FloodExLLC wants to merge 1 commit intoconversejs:masterfrom
FloodExLLC:fix/issue-2481
Open

feat: require current password when changing password (#3120)#3980
FloodExLLC wants to merge 1 commit intoconversejs:masterfrom
FloodExLLC:fix/issue-2481

Conversation

@FloodExLLC
Copy link
Copy Markdown

Summary

  • Adds a "Current password" field to the password reset form (closes Ask user to provide current password in order to reset password #3120)
  • Verifies the current password against the stored connection password when available, preventing unauthorized password changes when someone has access to the browser
  • Adds error message display when the current password is incorrect

Changes

  • src/plugins/profile/password-reset.js: Added current_password_error property and checkCurrentPassword() method
  • src/plugins/profile/templates/password-reset.js: Added "Current password" input field with error display
  • src/plugins/profile/tests/password-reset.js: Added test for incorrect current password, updated helper to include current password

Test plan

  • Existing password reset tests pass with updated helper (uses correct password secret)
  • New test verifies that submitting with wrong current password shows error and sends no IQ stanzas
  • Form requires current password field (marked required)

?? Generated with Claude Code

…js#3120)

Add a "Current password" field to the password reset form to prevent
unauthorized password changes when someone has access to the browser.
The current password is verified client-side against the stored
connection password when available.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
const form_data = new FormData(ev.target.form ?? ev.target);
const current_password = form_data.get('current_password');
const connection = api.connection.get();
if (connection?.pass && current_password !== connection.pass) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't going to work in all cases. When you reconnected via BOSH or XEP-0198 then the password won't be set on the connection object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To properly test the existing password, you might have to create a new Strophe.Connection object (using the subclass in Converse is likely overkill) and then test logging in with that connection and the provided password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ask user to provide current password in order to reset password

3 participants