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

(-)a/C4/Members.pm (-6 / +7 lines)
Lines 2472-2488 sub AddMember_Opac { Link Here
2472
    my ( %borrower ) = @_;
2472
    my ( %borrower ) = @_;
2473
2473
2474
    $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2474
    $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory');
2475
2475
    if (not defined $borrower{'password'}){
2476
    my $sr = new String::Random;
2476
        my $sr = new String::Random;
2477
    $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2477
        $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ];
2478
    my $password = $sr->randpattern("AAAAAAAAAA");
2478
        my $password = $sr->randpattern("AAAAAAAAAA");
2479
    $borrower{'password'} = $password;
2479
        $borrower{'password'} = $password;
2480
    }
2480
2481
2481
    $borrower{'cardnumber'} = fixup_cardnumber();
2482
    $borrower{'cardnumber'} = fixup_cardnumber();
2482
2483
2483
    my $borrowernumber = AddMember(%borrower);
2484
    my $borrowernumber = AddMember(%borrower);
2484
2485
2485
    return ( $borrowernumber, $password );
2486
    return ( $borrowernumber, $borrower{'password'} );
2486
}
2487
}
2487
2488
2488
=head2 AddEnrolmentFeeIfNeeded
2489
=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 777-784 Link Here
777
                [% END %]
779
                [% END %]
778
780
779
                [% UNLESS action == 'edit' %]
781
                [% UNLESS action == 'edit' %]
782
                    <fieldset class="rows" id="memberentry_password">
783
                        <legend id="contact_legend">Contact information</legend>
784
                    [% UNLESS hidden.defined('password') %]
785
                        <div class="alert alert-info">Your password must be at least [% minpassw %] characters long.
786
                        [% IF mandatory.defined('password') %]
787
                            <br>You must enter a password!</div>
788
                            <ol>
789
                                <li><label for="borrower_password" class="required">Password</label>
790
                                    <input type="text" name="borrower_password" id="password" />
791
                                </li>
792
                                <li><label for="borrower_password2" class="required">Confirm password</label>
793
                                    <input type="text" name="borrower_password2" id="password2" />
794
                                </li>
795
                            </ol>
796
                        [% ELSE %]
797
                            <br>If you do not enter a password a system generated password will be created</div>
798
                            <ol>
799
                                <li><label for="borrower_password">Password</label>
800
                                    <input type="text" name="borrower_password" id="password" />
801
                                </li>
802
                                <li><label for="borrower_password2">Confirm password</label>
803
                                    <input type="text" name="borrower_password2" id="password2" />
804
                                </li>
805
                            </ol>
806
                        [% END %]
807
                    [% END %]
808
                    </fieldset>
809
780
                    <fieldset class="rows" id="memberentry_captcha">
810
                    <fieldset class="rows" id="memberentry_captcha">
781
                        <ol>
811
                        <ol>
812
782
                            <li>
813
                            <li>
783
                                <label for="captcha" class="required">Verification:</label>
814
                                <label for="captcha" class="required">Verification:</label>
784
815
(-)a/opac/opac-memberentry.pl (-1 / +9 lines)
Lines 67-72 $template->param( Link Here
67
    action            => $action,
67
    action            => $action,
68
    hidden            => $hidden,
68
    hidden            => $hidden,
69
    mandatory         => $mandatory,
69
    mandatory         => $mandatory,
70
    minpassw          => C4::Context->preference('minPasswordLength'),
70
    member_titles     => GetTitles() || undef,
71
    member_titles     => GetTitles() || undef,
71
    branches          => GetBranchesLoop(),
72
    branches          => GetBranchesLoop(),
72
    OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
73
    OPACPatronDetails => C4::Context->preference('OPACPatronDetails'),
Lines 114-120 if ( $action eq 'create' ) { Link Here
114
115
115
            my $verification_token = md5_hex( \%borrower );
116
            my $verification_token = md5_hex( \%borrower );
116
            $borrower{'password'} = random_string("..........");
117
            $borrower{'password'} = random_string("..........");
117
118
            Koha::Borrower::Modifications->new(
118
            Koha::Borrower::Modifications->new(
119
                verification_token => $verification_token )
119
                verification_token => $verification_token )
120
              ->AddModifications(\%borrower);
120
              ->AddModifications(\%borrower);
Lines 308-313 sub CheckMandatoryFields { Link Here
308
}
308
}
309
309
310
sub CheckForInvalidFields {
310
sub CheckForInvalidFields {
311
    my $minpw = C4::Context->preference('minPasswordLength');
311
    my $borrower = shift;
312
    my $borrower = shift;
312
    my @invalidFields;
313
    my @invalidFields;
313
    if ($borrower->{'email'}) {
314
    if ($borrower->{'email'}) {
Lines 319-324 sub CheckForInvalidFields { Link Here
319
    if ($borrower->{'B_email'}) {
320
    if ($borrower->{'B_email'}) {
320
        push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'}));
321
        push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'}));
321
    }
322
    }
323
    if ( $borrower->{'password'} ne $borrower->{'password2'} ){
324
        push(@invalidFields, "password_match");
325
    }
326
    if ( $borrower->{'password'}  && $minpw && (length($borrower->{'password'}) < $minpw) ) {
327
       push(@invalidFields, "password_invalid");
328
    }
329
322
    return \@invalidFields;
330
    return \@invalidFields;
323
}
331
}
324
332
(-)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