Skip to content

Conversation

@frankiejol
Copy link
Member

When the user changes the password, expiration date and change request are reset. Also move user admin creation after init on testing security policy.

@frankiejol frankiejol added this to the v2.4.3 milestone Jan 12, 2026
Copilot AI review requested due to automatic review settings January 12, 2026 10:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes password management by ensuring that when a user changes their password, both the password expiration date and the change request flag are reset to 0. It also corrects a test initialization issue where user_admin was being called before the test environment was initialized.

Changes:

  • Updated change_password method to reset password_expiration_date and change_password fields to 0
  • Added test coverage to verify password status is properly reset after password change
  • Moved user_admin initialization to after init() call in security policy test

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/Ravada/Auth/SQL.pm Modified change_password to update password_expiration_date and change_password fields, refactored method signature to use modern Perl signatures
t/user/50_admin.t Added test case to verify password expiration and change request flags are reset to 0 after password change
t/mojo/40_security_policy.t Moved user_admin variable initialization to after init() call to ensure proper test environment setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +572 to +575
$sth= $$CON->dbh->prepare("UPDATE users "
." set password=?, change_password=?, password_expiration_date=?"
." WHERE id=?");
$sth->execute(sha1_hex($password), ($force_change_password or 0) ,0, $self->id);
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The change_password implementation is still storing user passwords using a plain SHA1 hash via sha1_hex($password) before writing to the users table. SHA1 without a dedicated password hashing scheme (e.g., bcrypt, scrypt, Argon2) is fast and unsalted, making it practical for attackers to crack large numbers of passwords offline if the database is ever compromised. Replace this with a modern, slow, and salted password hashing function from a well-vetted library and migrate existing hashes where possible.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Jan 12, 2026

@frankiejol I've opened a new pull request, #2275, to work on those changes. Once the pull request is ready, I'll request review from you.

@frankiejol frankiejol changed the title fix: refresh user status when chaning pwd fix: refresh user status when changing pwd Jan 12, 2026
@frankiejol frankiejol merged commit f7170aa into main Jan 12, 2026
1 check passed
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.

2 participants