3 # This file is part of Koha.
5 # Copyright 2019 Koha Development Team
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
26 my ( $help, $password, $cardnumber, $patron_id, $userid );
29 'userid=s' => \$userid,
30 'password=s' => \$password,
31 'patron_id=s' => \$patron_id,
32 'cardnumber=s' => \$cardnumber,
35 pod2usage(1) if $help;
36 pod2usage("password is mandatory") unless $password;
38 unless ( $userid or $patron_id or $cardnumber ) {
39 pod2usage("userid is mandatory") unless $userid;
40 pod2usage("patron_id is mandatory") unless $patron_id;
41 pod2usage("cardnumber is mandatory") unless $cardnumber;
47 $filter->{userid} = $userid;
51 $filter->{cardnumber} = $cardnumber;
55 $filter->{borrowernumber} = $patron_id;
58 my $patrons = Koha::Patrons->search( $filter );
60 unless ( $patrons->count > 0 ) {
61 pod2usage( "No patron found matching the specified criteria" );
64 my $patron = $patrons->next;
65 $patron->set_password({ password => $password, skip_validation => 1 });
69 set_password.pl - Set the specified password for the user in Koha
74 --userid <userid> --password <password> --patron_id <patron_id> --cardnumber <cardnumber>
77 -?|--help brief help message
78 --password the password to be set
79 --userid the userid to be used to find the patron
80 --patron_id the borrowernumber for the patron
81 --cardnumber the cardnumber for the patron
89 Print a brief help message and exits
93 The patron's userid (for finding the patron)
97 The password to be set in the database
101 The patron's internal id (for finding the patron)
103 =item B<--cardnumber>
105 Patron's cardnumber (for finding the patron)
111 A simple script to change an existing's user password in the Koha database