User password reset question
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
Hi Stephen, you can use Koha::AuthUtils::hash_password to encode password and then Koha::Patron->update_password($userid, $newPassword) you can see it in members/member-password.pl script on lines 73 and 76 in 16.11 code Hope that helps Josef po 26. 3. 2018 v 17:09 odesílatel Graham, Stephen <s.graham4@herts.ac.uk> napsal:
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/
Thanks Josef – I couldn’t see the Koha::Patron module listed at: https://perldoc.koha-community.org/16.11.x/ . But It is there on our Koha server. Looking at the perldoc for that module I can see the update_password method. Will give it a go! Cheers, Stephen From: Josef Moravec <josef.moravec@gmail.com> Sent: 26 March 2018 16:25 To: Graham, Stephen <s.graham4@herts.ac.uk> Cc: koha-devel@lists.koha-community.org Subject: Re: [Koha-devel] User password reset question Hi Stephen, you can use Koha::AuthUtils::hash_password to encode password and then Koha::Patron->update_password($userid, $newPassword) you can see it in members/member-password.pl<http://member-password.pl> script on lines 73 and 76 in 16.11 code Hope that helps Josef po 26. 3. 2018 v 17:09 odesílatel Graham, Stephen <s.graham4@herts.ac.uk<mailto:s.graham4@herts.ac.uk>> napsal: 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<http://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<mailto:s.graham4@herts.ac.uk> _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org<mailto: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/
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/
participants (3)
-
Graham, Stephen -
Jonathan Druart -
Josef Moravec