Bugzilla – Attachment 47407 Details for
Bug 15343
Allow patrons to choose their own password on self registration.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15343 - Allow user to set password on opac-memberentry.pl
Bug-15343---Allow-user-to-set-password-on-opac-mem.patch (text/plain), 9.24 KB, created by
Mirko Tietgen
on 2016-01-28 20:03:03 UTC
(
hide
)
Description:
Bug 15343 - Allow user to set password on opac-memberentry.pl
Filename:
MIME Type:
Creator:
Mirko Tietgen
Created:
2016-01-28 20:03:03 UTC
Size:
9.24 KB
patch
obsolete
>From 704b9be868e4bac6378543a2f3f43d820bc35097 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Sat, 12 Dec 2015 02:10:06 +0000 >Subject: [PATCH] Bug 15343 - Allow user to set password on opac-memberentry.pl > >This patch allows patrons to create thier own password during OPAC self >registration. It sets the password field to be hidden by default, and >allows for a system generated password if no password is supplied and >field is not mandatory > >1 - Apply patch >2 - run updatedatabase.pl >3 - Check syspref "PatronSelfRegistrationBorrowerUnwantedField" - it >should contain 'password' >4 - Check self registration on opac - there should be no change >5 - Remove 'password' from PatronSelfRegistrationBorrowerUnwantedField >6 - Password field should now be visible in OPAC self registration >7 - Register a patron: If no passwor is supplied you should get a system >generated password >8 - Register a patron with a password, your password should be used >9 - Add 'password' to PatronSelfRegistrationBorrowerMnadatoryField >10 - Attempt to register a patron with no password - it should fail >11 - Try all combinations if mismatched/short/missing passwords and view >correct error messages >12 - prove t/db_dependent/Members.t > >Sponsored by : Do Space (www.dospace.org) > >Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com> >Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> >--- > C4/Members.pm | 13 ++++----- > ...RegistrationBorrowrUnwantedField_by_default.sql | 1 + > .../bootstrap/en/modules/opac-memberentry.tt | 31 ++++++++++++++++++++++ > opac/opac-memberentry.pl | 10 ++++++- > t/db_dependent/Members.t | 11 +++++++- > 5 files changed, 58 insertions(+), 8 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_15343-add_password_to_PatronSelfRegistrationBorrowrUnwantedField_by_default.sql > >diff --git a/C4/Members.pm b/C4/Members.pm >index 4ba1f19..2a56461 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -2472,17 +2472,18 @@ sub AddMember_Opac { > my ( %borrower ) = @_; > > $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >- >- my $sr = new String::Random; >- $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ]; >- my $password = $sr->randpattern("AAAAAAAAAA"); >- $borrower{'password'} = $password; >+ if (not defined $borrower{'password'}){ >+ my $sr = new String::Random; >+ $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ]; >+ my $password = $sr->randpattern("AAAAAAAAAA"); >+ $borrower{'password'} = $password; >+ } > > $borrower{'cardnumber'} = fixup_cardnumber(); > > my $borrowernumber = AddMember(%borrower); > >- return ( $borrowernumber, $password ); >+ return ( $borrowernumber, $borrower{'password'} ); > } > > =head2 AddEnrolmentFeeIfNeeded >diff --git a/installer/data/mysql/atomicupdate/bug_15343-add_password_to_PatronSelfRegistrationBorrowrUnwantedField_by_default.sql b/installer/data/mysql/atomicupdate/bug_15343-add_password_to_PatronSelfRegistrationBorrowrUnwantedField_by_default.sql >new file mode 100644 >index 0000000..0f3ad0f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_15343-add_password_to_PatronSelfRegistrationBorrowrUnwantedField_by_default.sql >@@ -0,0 +1 @@ >+UPDATE systempreferences SET value = CONCAT_WS('|', IF(value='', NULL, value), "password") WHERE variable="PatronSelfRegistrationBorrowerUnwantedField" AND value NOT LIKE "%password%"; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 3f3428d..90f4b83 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -60,6 +60,8 @@ > [% IF field == "email" %]<li>Contact information: <a href="#borrower_email">primary email address</a></li>[% END %] > [% IF field == "emailpro" %]<li>Contact information: <a href="#borrower_emailpro">secondary email address</a></li>[% END %] > [% IF field == "B_email" %]<li>Alternate address information: <a href="#borrower_B_email">email address</a></li>[% END %] >+ [% IF field == "password_match" %]<li>Passwords do not match! <a href="#password">password</a></li>[% END %] >+ [% IF field == "password_invalid" %]<li>Password does not meet minium requirements! <a href="#password">password</a></li>[% END %] > [% END %] > </ul> > Please correct the errors and resubmit. >@@ -777,8 +779,37 @@ > [% END %] > > [% UNLESS action == 'edit' %] >+ <fieldset class="rows" id="memberentry_password"> >+ <legend id="contact_legend">Contact information</legend> >+ [% UNLESS hidden.defined('password') %] >+ <div class="alert alert-info">Your password must be at least [% minpassw %] characters long. >+ [% IF mandatory.defined('password') %] >+ <br>You must enter a password!</div> >+ <ol> >+ <li><label for="borrower_password" class="required">Password</label> >+ <input type="text" name="borrower_password" id="password" /> >+ </li> >+ <li><label for="borrower_password2" class="required">Confirm password</label> >+ <input type="text" name="borrower_password2" id="password2" /> >+ </li> >+ </ol> >+ [% ELSE %] >+ <br>If you do not enter a password a system generated password will be created</div> >+ <ol> >+ <li><label for="borrower_password">Password</label> >+ <input type="text" name="borrower_password" id="password" /> >+ </li> >+ <li><label for="borrower_password2">Confirm password</label> >+ <input type="text" name="borrower_password2" id="password2" /> >+ </li> >+ </ol> >+ [% END %] >+ [% END %] >+ </fieldset> >+ > <fieldset class="rows" id="memberentry_captcha"> > <ol> >+ > <li> > <label for="captcha" class="required">Verification:</label> > >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 667f201..fcf94cf 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -67,6 +67,7 @@ $template->param( > action => $action, > hidden => $hidden, > mandatory => $mandatory, >+ minpassw => C4::Context->preference('minPasswordLength'), > member_titles => GetTitles() || undef, > branches => GetBranchesLoop(), > OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), >@@ -114,7 +115,6 @@ if ( $action eq 'create' ) { > > my $verification_token = md5_hex( \%borrower ); > $borrower{'password'} = random_string(".........."); >- > Koha::Borrower::Modifications->new( > verification_token => $verification_token ) > ->AddModifications(\%borrower); >@@ -308,6 +308,7 @@ sub CheckMandatoryFields { > } > > sub CheckForInvalidFields { >+ my $minpw = C4::Context->preference('minPasswordLength'); > my $borrower = shift; > my @invalidFields; > if ($borrower->{'email'}) { >@@ -319,6 +320,13 @@ sub CheckForInvalidFields { > if ($borrower->{'B_email'}) { > push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'})); > } >+ if ( $borrower->{'password'} ne $borrower->{'password2'} ){ >+ push(@invalidFields, "password_match"); >+ } >+ if ( $borrower->{'password'} && $minpw && (length($borrower->{'password'}) < $minpw) ) { >+ push(@invalidFields, "password_invalid"); >+ } >+ > return \@invalidFields; > } > >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index 4c87e84..13e6b57 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 74; >+use Test::More tests => 76; > use Test::MockModule; > use Data::Dumper; > use C4::Context; >@@ -365,6 +365,15 @@ sub _find_member { > return $found; > } > >+# Regression tests for BZ15343 >+my $password=""; >+( $borrowernumber, $password ) = AddMember_Opac(surname=>"Dick",firstname=>'Philip',branchcode => $library2->{branchcode}); >+is( $password =~ /^[a-zA-Z]{10}$/ , 1, 'Test for autogenerated password if none submitted'); >+( $borrowernumber, $password ) = AddMember_Opac(surname=>"Deckard",firstname=>"Rick",password=>"Nexus-6",branchcode => $library2->{branchcode}); >+is( $password eq "Nexus-6", 1, 'Test password used if submitted'); >+ >+ >+ > ### ------------------------------------- ### > ### Testing GetAge() / SetAge() functions ### > ### ------------------------------------- ### >-- >2.1.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 15343
:
45861
|
45866
|
45867
|
45868
|
45869
|
46705
|
46737
|
47320
|
47321
|
47322
|
47407
|
47408
|
47409
|
47705
|
47794
|
47795
|
47796
|
47797