Hi Stephen,

You need to hash it before, takes a look at members/member-password.pl
In master, it will be something like:

my $digest = Koha::AuthUtils::hash_password( $new_password );
Koha::Patrons->find( $borrowernumber )->update_password($uid, $digest);

The method is badly named as it could also update the user id (login).

Or hash it first then use a SQL query:
UPDATE borrowers set password=? WHERE borrowernumber=?

Let me know if you need something more precise.

Regards,
Jonathan

On Mon, 26 Mar 2018 at 12:09 Graham, Stephen <s.graham4@herts.ac.uk> wrote:

Hi All – if I wanted to programmatically change a user’s password what would the best way of doing this? I’ve just been looking at the various Perl modules for our version of Koha (16.11). modules such as C4:Members, C4:Member:Attributes  etc, but cannot see any methods that can reset the password. Looking at the opac-passwd.pl CGI script which is called when changing a user password, I see that it uses a SQL update to change the password. Is this the best route to go if I wanted to change a password?

 

Cheers, Stephen

 

--------------------------------------

Stephen Graham

Library Technology Consultant

Content and Collections Team

Library and Computing Services

University of Hertfordshire

Tel: 01707 286111

Ext: 77751

Email: s.graham4@herts.ac.uk

 

 

_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/