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

(-)a/C4/Members.pm (-6 / +7 lines)
Lines 2483-2499 sub AddMember_Opac { Link Here
2483
    my ( %borrower ) = @_;
2483
    my ( %borrower ) = @_;
2484
2484
2485
    $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2485
    $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2486
2486
    if (not defined $borrower{'password'}){
2487
    my $sr = new String::Random;
2487
        my $sr = new String::Random;
2488
    $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2488
        $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2489
    my $password = $sr->randpattern("AAAAAAAAAA");
2489
        my $password = $sr->randpattern("AAAAAAAAAA");
2490
    $borrower{'password'} = $password;
2490
        $borrower{'password'} = $password;
2491
    }
2491
2492
2492
    $borrower{'cardnumber'} = fixup_cardnumber();
2493
    $borrower{'cardnumber'} = fixup_cardnumber();
2493
2494
2494
    my $borrowernumber = AddMember(%borrower);
2495
    my $borrowernumber = AddMember(%borrower);
2495
2496
2496
    return ( $borrowernumber, $password );
2497
    return ( $borrowernumber, $borrower{'password'} );
2497
}
2498
}
2498
2499
2499
=head2 AddEnrolmentFeeIfNeeded
2500
=head2 AddEnrolmentFeeIfNeeded
(-)a/installer/data/mysql/atomicupdate/bug_15343-add_password_to_PatronSelfRegistrationBorrowrUnwantedField_by_default.sql (+1 lines)
Line 0 Link Here
1
UPDATE systempreferences SET value = CONCAT_WS('|', IF(value='', NULL, value), "password") WHERE variable="PatronSelfRegistrationBorrowerUnwantedField" AND value NOT LIKE "%password%";
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (+31 lines)
Lines 60-65 Link Here
60
                                [% IF field == "email" %]<li>Contact information: <a href="#borrower_email">primary email address</a></li>[% END %]
60
                                [% IF field == "email" %]<li>Contact information: <a href="#borrower_email">primary email address</a></li>[% END %]
61
                                [% IF field == "emailpro" %]<li>Contact information: <a href="#borrower_emailpro">secondary email address</a></li>[% END %]
61
                                [% IF field == "emailpro" %]<li>Contact information: <a href="#borrower_emailpro">secondary email address</a></li>[% END %]
62
                                [% IF field == "B_email" %]<li>Alternate address information: <a href="#borrower_B_email">email address</a></li>[% END %]
62
                                [% IF field == "B_email" %]<li>Alternate address information: <a href="#borrower_B_email">email address</a></li>[% END %]
63
                                [% IF field == "password_match" %]<li>Passwords do not match! <a href="#password">password</a></li>[% END %]
64
                                [% IF field == "password_invalid" %]<li>Password does not meet minium requirements! <a href="#password">password</a></li>[% END %]
63
                            [% END %]
65
                            [% END %]
64
                        </ul>
66
                        </ul>
65
                        Please correct the errors and resubmit.
67
                        Please correct the errors and resubmit.
Lines 751-758 Link Here
751
                [% END %]
753
                [% END %]
752
754
753
                [% UNLESS action == 'edit' %]
755
                [% UNLESS action == 'edit' %]
756
                    <fieldset class="rows" id="memberentry_password">
757
                        <legend id="contact_legend">Contact information</legend>
758
                    [% UNLESS hidden.defined('password') %]
759
                        <div class="alert alert-info">Your password must be at least [% minpassw %] characters long.
760
                        [% IF mandatory.defined('password') %]
761
                            <br>You must enter a password!</div>
762
                            <ol>
763
                                <li><label for="borrower_password" class="required">Password</label>
764
                                    <input type="text" name="borrower_password" id="password" />
765
                                </li>
766
                                <li><label for="borrower_password2" class="required">Confirm password</label>
767
                                    <input type="text" name="borrower_password2" id="password2" />
768
                                </li>
769
                            </ol>
770
                        [% ELSE %]
771
                            <br>If you do not enter a password a system generated password will be created</div>
772
                            <ol>
773
                                <li><label for="borrower_password">Password</label>
774
                                    <input type="text" name="borrower_password" id="password" />
775
                                </li>
776
                                <li><label for="borrower_password2">Confirm password</label>
777
                                    <input type="text" name="borrower_password2" id="password2" />
778
                                </li>
779
                            </ol>
780
                        [% END %]
781
                    [% END %]
782
                    </fieldset>
783
754
                    <fieldset class="rows" id="memberentry_captcha">
784
                    <fieldset class="rows" id="memberentry_captcha">
755
                        <ol>
785
                        <ol>
786
756
                            <li>
787
                            <li>
757
                                <label for="captcha" class="required">Verification:</label>
788
                                <label for="captcha" class="required">Verification:</label>
758
789
(-)a/opac/opac-memberentry.pl (-1 / +9 lines)
Lines 66-71 $template->param( Link Here
66
    action            => $action,
66
    action            => $action,
67
    hidden            => $hidden,
67
    hidden            => $hidden,
68
    mandatory         => $mandatory,
68
    mandatory         => $mandatory,
69
    minpassw          => C4::Context->preference('minPasswordLength'),
69
    member_titles     => GetTitles() || undef,
70
    member_titles     => GetTitles() || undef,
70
    branches          => GetBranchesLoop(),
71
    branches          => GetBranchesLoop(),
71
    OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
72
    OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
Lines 113-119 if ( $action eq 'create' ) { Link Here
113
114
114
            my $verification_token = md5_hex( \%borrower );
115
            my $verification_token = md5_hex( \%borrower );
115
            $borrower{'password'} = random_string("..........");
116
            $borrower{'password'} = random_string("..........");
116
117
            Koha::Borrower::Modifications->new(
117
            Koha::Borrower::Modifications->new(
118
                verification_token => $verification_token )
118
                verification_token => $verification_token )
119
              ->AddModifications(\%borrower);
119
              ->AddModifications(\%borrower);
Lines 305-310 sub CheckMandatoryFields { Link Here
305
}
305
}
306
306
307
sub CheckForInvalidFields {
307
sub CheckForInvalidFields {
308
    my $minpw = C4::Context->preference('minPasswordLength');
308
    my $borrower = shift;
309
    my $borrower = shift;
309
    my @invalidFields;
310
    my @invalidFields;
310
    if ($borrower->{'email'}) {
311
    if ($borrower->{'email'}) {
Lines 316-321 sub CheckForInvalidFields { Link Here
316
    if ($borrower->{'B_email'}) {
317
    if ($borrower->{'B_email'}) {
317
        push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'}));
318
        push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'}));
318
    }
319
    }
320
    if ( $borrower->{'password'} ne $borrower->{'password2'} ){
321
        push(@invalidFields, "password_match");
322
    }
323
    if ( $borrower->{'password'}  && $minpw && (length($borrower->{'password'}) < $minpw) ) {
324
       push(@invalidFields, "password_invalid");
325
    }
326
319
    return \@invalidFields;
327
    return \@invalidFields;
320
}
328
}
321
329
(-)a/t/db_dependent/Members.t (-2 / +10 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 74;
20
use Test::More tests => 76;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Data::Dumper;
22
use Data::Dumper;
23
use C4::Context;
23
use C4::Context;
Lines 365-370 sub _find_member { Link Here
365
    return $found;
365
    return $found;
366
}
366
}
367
367
368
# Regression tests for BZ15343
369
my $password="";
370
( $borrowernumber, $password ) = AddMember_Opac(surname=>"Dick",firstname=>'Philip',branchcode => $library2->{branchcode});
371
is( $password =~ /^[a-zA-Z]{10}$/ , 1, 'Test for autogenerated password if none submitted');
372
( $borrowernumber, $password ) = AddMember_Opac(surname=>"Deckard",firstname=>"Rick",password=>"Nexus-6",branchcode => $library2->{branchcode});
373
is( $password eq "Nexus-6", 1, 'Test password used if submitted');
374
375
376
368
### ------------------------------------- ###
377
### ------------------------------------- ###
369
### Testing GetAge() / SetAge() functions ###
378
### Testing GetAge() / SetAge() functions ###
370
### ------------------------------------- ###
379
### ------------------------------------- ###
371
- 

Return to bug 15343