View | Details | Raw Unified | Return to bug 23473
Collapse All | Expand All

(-)a/Koha/Patrons/Import.pm (-1 / +1 lines)
Lines 290-296 sub import_patrons { Link Here
290
                    );
290
                    );
291
                }
291
                }
292
            }
292
            }
293
            if ($overwrite_passwords){
293
            if ($overwrite_passwords && defined $borrower{password} && $borrower{password} ne ''){
294
                try {
294
                try {
295
                    $patron->set_password({ password => $borrower{password} });
295
                    $patron->set_password({ password => $borrower{password} });
296
                }
296
                }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt (-1 / +1 lines)
Lines 248-254 Link Here
248
                    <ul>
248
                    <ul>
249
                        <li>
249
                        <li>
250
                            <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/>
250
                            <input class="overwrite_passwords" type="checkbox" id="overwrite_passwords" name="overwrite_passwords" disabled/>
251
                            <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file</label>
251
                            <label class="overwrite_passwords" for="overwrite_passwords">Replace patron passwords with those in the file (blank passwords will be ignored)</label>
252
                        </li
252
                        </li
253
                    </ul>
253
                    </ul>
254
                </li>
254
                </li>
(-)a/t/db_dependent/Koha/Patrons/Import.t (-2 / +14 lines)
Lines 432-438 subtest 'test_import_with_cardnumber_0' => sub { Link Here
432
};
432
};
433
433
434
subtest 'test_import_with_password_overwrite' => sub {
434
subtest 'test_import_with_password_overwrite' => sub {
435
    plan tests => 4;
435
    plan tests => 6;
436
436
437
    #Remove possible existing user to avoid clashes
437
    #Remove possible existing user to avoid clashes
438
    my $ernest = Koha::Patrons->find({ userid => 'ErnestP' });
438
    my $ernest = Koha::Patrons->find({ userid => 'ErnestP' });
Lines 444-449 subtest 'test_import_with_password_overwrite' => sub { Link Here
444
    my $csv_headers  = 'surname,userid,branchcode,categorycode,password';
444
    my $csv_headers  = 'surname,userid,branchcode,categorycode,password';
445
    my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1";
445
    my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest1";
446
    my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1";
446
    my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1";
447
    my $csv_blank_password = "Worel,ErnestP,$branchcode,$categorycode,";
447
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
448
    my $defaults = { cardnumber => "" }; #currently all the defaults come as "" if not filled
448
449
449
    #Make the test files for importing
450
    #Make the test files for importing
Lines 454-459 subtest 'test_import_with_password_overwrite' => sub { Link Here
454
    open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!";
455
    open(my $handle_2, "<", $filename_2) or die "cannot open < $filename_2: $!";
455
    my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1};
456
    my $params_2 = { file => $handle_2, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1};
456
457
458
    my $filename_3 = make_csv($temp_dir, $csv_headers, $csv_blank_password);
459
    open(my $handle_3, "<", $filename_3) or die "cannot open < $filename_3: $!";
460
    my $params_3 = { file => $handle_3, matchpoint => 'userid', overwrite_passwords => 1, overwrite_cardnumber => 1};
461
457
462
458
    my $result = $patrons_import->import_patrons($params_1, $defaults);
463
    my $result = $patrons_import->import_patrons($params_1, $defaults);
459
    like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected');
464
    like($result->{feedback}->[1]->{value}, qr/^Worrell \/ \d+/, 'First borrower imported as expected');
Lines 468-473 subtest 'test_import_with_password_overwrite' => sub { Link Here
468
    isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten");
473
    isnt($ernest->password,$orig_pass,"New patron is overwritten, password is overwritten");
469
    isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided");
474
    isnt($ernest->password,'Vern',"Password is overwritten and is encrypted from value provided");
470
475
476
    #Save info to check not changed
477
    $orig_pass = $ernest->password;
478
479
    $result = $patrons_import->import_patrons($params_3, $defaults);
480
    $ernest = Koha::Patrons->find({ userid => 'ErnestP' });
481
    is($ernest->surname,'Worel',"Patron is overwritten, surname changed");
482
    is($ernest->password,$orig_pass,"Patron was overwritten but password is not overwritten if blank");
483
471
};
484
};
472
485
473
486
474
- 

Return to bug 23473