Bugzilla – Attachment 84899 Details for
Bug 17746
koha-reset-passwd should use Koha::Patron->set_password
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17746: Add misc/admin/set_password.pl script
Bug-17746-Add-miscadminsetpasswordpl-script.patch (text/plain), 4.36 KB, created by
Pierre-Marc Thibault
on 2019-02-08 20:24:14 UTC
(
hide
)
Description:
Bug 17746: Add misc/admin/set_password.pl script
Filename:
MIME Type:
Creator:
Pierre-Marc Thibault
Created:
2019-02-08 20:24:14 UTC
Size:
4.36 KB
patch
obsolete
>From 18450767eb6cdfb8b73616dc9044b995d7545f0b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 4 Feb 2019 15:09:34 -0300 >Subject: [PATCH] Bug 17746: Add misc/admin/set_password.pl script > >This patch introduces a script that allows changing a patron's password. >The change overrides the defined password enforcement policy. > >If multiple conditions are passed to match on the patron, they all need >to match. Otherwise an error message is printed. > >Attributes to search the patron on: >- cardnumber >- patron_id (a.k.a. borrowernumber) >- userid > >we usually know some of them, but if we specify more than one, they need >to match a patron, together. > >To test: >1) Apply this patch >2) Have a known patron (i.e. you know the cardnumber, the borrowernumber > and the userid). >3) Run: > $ kshell > k$ perl misc/admin/set_password.pl --cardnumber <the_card_number> \ > --password a_password >4) Verify you can login with the new password >5) Repeat 3) through 5) with --patron_id and --userid >=> SUCCESS: You can login in all cases >6) Try combining some or all the parameters >=> SUCCESS: It fails when it should, it succeeds when it should >7) Sign off :-D > >Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com> >--- > misc/admin/set_password.pl | 113 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 113 insertions(+) > create mode 100755 misc/admin/set_password.pl > >diff --git a/misc/admin/set_password.pl b/misc/admin/set_password.pl >new file mode 100755 >index 0000000..8ae1444 >--- /dev/null >+++ b/misc/admin/set_password.pl >@@ -0,0 +1,113 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2019 Koha Development Team >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Getopt::Long; >+use Pod::Usage; >+ >+use Koha::Patrons; >+ >+my ( $help, $password, $cardnumber, $patron_id, $userid ); >+GetOptions( >+ 'help|?' => \$help, >+ 'userid=s' => \$userid, >+ 'password=s' => \$password, >+ 'patron_id=s' => \$patron_id, >+ 'cardnumber=s' => \$cardnumber, >+); >+ >+pod2usage(1) if $help; >+pod2usage("password is mandatory") unless $password; >+ >+unless ( $userid or $patron_id or $cardnumber ) { >+ pod2usage("userid is mandatory") unless $userid; >+ pod2usage("patron_id is mandatory") unless $patron_id; >+ pod2usage("cardnumber is mandatory") unless $cardnumber; >+} >+ >+my $filter; >+ >+if ( $userid ) { >+ $filter->{userid} = $userid; >+} >+ >+if ( $cardnumber ) { >+ $filter->{cardnumber} = $cardnumber; >+} >+ >+if ( $patron_id ) { >+ $filter->{borrowernumber} = $patron_id; >+} >+ >+my $patrons = Koha::Patrons->search( $filter ); >+ >+unless ( $patrons->count > 0 ) { >+ pod2usage( "No patron found matching the specified criteria" ); >+} >+ >+my $patron = $patrons->next; >+$patron->set_password({ password => $password, skip_validation => 1 }); >+ >+=head1 NAME >+ >+set_password.pl - Set the specified password for the user in Koha >+ >+=head1 SYNOPSIS >+ >+set_password.pl >+ --userid <userid> --password <password> --patron_id <patron_id> --cardnumber <cardnumber> >+ >+ Options: >+ -?|--help brief help message >+ --password the password to be set >+ --userid the userid to be used to find the patron >+ --patron_id the borrowernumber for the patron >+ --cardnumber the cardnumber for the patron >+ >+=head1 OPTIONS >+ >+=over 8 >+ >+=item B<--help|-?> >+ >+Print a brief help message and exits >+ >+=item B<--userid> >+ >+The patron's userid (for finding the patron) >+ >+=item B<--password> >+ >+The password to be set in the database >+ >+=item B<--patron_id> >+ >+The patron's internal id (for finding the patron) >+ >+=item B<--cardnumber> >+ >+Patron's cardnumber (for finding the patron) >+ >+=back >+ >+=head1 DESCRIPTION >+ >+A simple script to change an existing's user password in the Koha database >+ >+=cut >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17746
:
84797
|
84798
|
84898
|
84899
|
85363
|
86932
|
86933
|
86934
|
86937
|
86938
|
86939