Bugzilla – Attachment 97002 Details for
Bug 23473
Add option to import/overwrite passwords when using the patron import tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23473: Don't allow setting blank passwords via import
Bug-23473-Dont-allow-setting-blank-passwords-via-i.patch (text/plain), 4.31 KB, created by
Nick Clemens (kidclamp)
on 2020-01-08 15:03:26 UTC
(
hide
)
Description:
Bug 23473: Don't allow setting blank passwords via import
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-01-08 15:03:26 UTC
Size:
4.31 KB
patch
obsolete
>From e51a855d68bb9a642ed669dba52d779c8a9b5a09 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 8 Jan 2020 14:24:04 +0000 >Subject: [PATCH] Bug 23473: Don't allow setting blank passwords via import > >--- > Koha/Patrons/Import.pm | 2 +- > .../prog/en/modules/tools/import_borrowers.tt | 2 +- > t/db_dependent/Koha/Patrons/Import.t | 15 ++++++++++++++- > 3 files changed, 16 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index 092ce09c46..2a605e2b7f 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -290,7 +290,7 @@ sub import_patrons { > ); > } > } >- if ($overwrite_passwords){ >+ if ($overwrite_passwords && defined $borrower{password} && $borrower{password} ne ''){ > try { > $patron->set_password({ password => $borrower{password} }); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >index 70fe71712b..915525de75 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >@@ -248,7 +248,7 @@ > <ul> > <li> > <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/> >- <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file</label> >+ <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file (blank passwords will be ignored)</label> > </li > </ul> > </li> >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index 26ca3c60fd..47dd5184e8 100644 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -432,7 +432,7 @@ subtest 'test_import_with_cardnumber_0' => sub { > }; > > subtest 'test_import_with_password_overwrite' => sub { >- plan tests => 4; >+ plan tests => 6; > > #Remove possible existing user to avoid clashes > my $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); >@@ -444,6 +444,7 @@ subtest 'test_import_with_password_overwrite' => sub { > my $csv_headers = 'surname,userid,branchcode,categorycode,password'; > my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1"; > my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1"; >+ my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,"; > my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled > > #Make the test files for importing >@@ -454,6 +455,10 @@ subtest 'test_import_with_password_overwrite' => sub { > open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!"; > my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; > >+ my $filename_3 = make_csv($temp_dir, $csv_headers, $csv_blank_password); >+ open(my $handle_3, "<", $filename_3) or die "cannot open < $filename_3: $!"; >+ my $params_3 = { file => $handle_3, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1}; >+ > > my $result = $patrons_import->import_patrons($params_1, $defaults); > like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected'); >@@ -468,6 +473,14 @@ subtest 'test_import_with_password_overwrite' => sub { > isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten"); > isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided"); > >+ #Save info to check not changed >+ $orig_pass = $ernest->password; >+ >+ $result = $patrons_import->import_patrons($params_3, $defaults); >+ $ernest = Koha::Patrons->find({ userid => 'ErnestP' }); >+ is($ernest->surname,'Worel',"Patron is overwritten, surname changed"); >+ is($ernest->password,$orig_pass,"Patron was overwritten but password is not overwritten if blank"); >+ > }; > > >-- >2.11.0
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 23473
:
92352
|
93073
|
93074
|
93594
|
94822
|
95049
|
95050
|
95051
|
95052
|
96998
|
96999
|
97000
|
97001
|
97002
|
97003
|
98382
|
101981
|
101982
|
101983
|
101984
|
101985
|
101986
|
101987
|
101988