Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Enables setting password expiration on user creation via Perl API. The default admin user now requires password change on first login.

Changes

  • lib/Ravada/Auth/SQL.pm: Added change_password parameter to add_user function

    • Accepts optional change_password => 1 argument
    • Defaults to 0 for backward compatibility
    • Inserts value into users.change_password column
  • lib/Ravada.pm: Set change_password => 1 for default admin user creation

  • t/user/50_admin.t: Added test verifying admin user password expiration

Usage

Ravada::Auth::SQL::add_user(
    name => 'admin',
    password => 'admin',
    is_admin => 1,
    change_password => 1  # Forces password change on first login
);

The password_will_be_changed() method returns the flag value for verification.

Original prompt

This section details on the original issue you should resolve

<issue_title>Set password to expired on create user</issue_title>
<issue_description>When creating an user from Perl API, allow parameter: change_password => 1

In file lib/Ravada/Auth/SQL.pm , at the sub add_user , accept the change_password parameter and insert it in the SQL like all the others there.

Also use it for creating the admin user in lib/Ravada.pm:

    Ravada::Auth::SQL::add_user(
        name => 'admin'
        ,password => 'admin'
        ,is_admin => 1
        ,change_password => 1
    );
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@frankiejol</author><body>
To test this change, add the last line to _t/user/50_admin.t_ at the sub _test_default_admin_, after checking the user is ok:

my $user = Ravada::Auth::login('admin','admin');
ok($user);
is($user->password_will_be_changed(),1);

Test it running _prove_ like this:

`prove -l t/user/50_admin.t`</body></comment_new>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: frankiejol <136835+frankiejol@users.noreply.github.com>
Copilot AI changed the title [WIP] Add change_password parameter on user creation Add change_password parameter to user creation API Dec 16, 2025
Copilot AI requested a review from frankiejol December 16, 2025 12:56
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.

Set password to expired on create user

2 participants