Bugzilla – Attachment 114161 Details for
Bug 27148
Internal Server Error during self registration 20.11
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27148: Fix bug on self registration when user category is hidden
Bug-27148-Fix-bug-on-self-registration-when-user-c.patch (text/plain), 5.17 KB, created by
David Nind
on 2020-12-03 18:43:37 UTC
(
hide
)
Description:
Bug 27148: Fix bug on self registration when user category is hidden
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-12-03 18:43:37 UTC
Size:
5.17 KB
patch
obsolete
>From ce3b788755a5032c52fbd48bb0cc87ba13a49dbc Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Thu, 3 Dec 2020 13:10:18 -0300 >Subject: [PATCH] Bug 27148: Fix bug on self registration when user category is > hidden > >This patch fixes the bug when there is no patron category available for >selection in self registration form. It uses PatronSelfRegistrationDefaultCategory >to get patron's password length and strength. > >To test: >1. Do not apply this patch >2. Allow SeflRegistration, set PatronSelfRegistrationDefaultCategory to > a valid patron category and finally add categorycode to PatronSelfRegistrationBorrowerUnwantedField >3. Go to opac and enter self registration form >CHECK => There is no patron category available for selection > => Password's info alert shows "Password must contain at least >undefined characters" >4. Fill the form setting a password and send. >CHECH => You get an exception saying "You must provide a patron's >category to validate password's strength and length" >5. Apply this patch and restart_all >6. repeat steps 3 and 4 >SUCCESS => Password's info alert message shows a number instead of >"undefined" > => Password's strength and length checks are working > => If you change default category's lenght or strength parameter it get's reflected when you refresh the page > => When you click send, patron is saved > >Signed-off-by: David Nind <david@davidnind.com> >--- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt | 8 +++++--- > opac/opac-memberentry.pl | 5 ++++- > 2 files changed, 9 insertions(+), 4 deletions(-) > >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 6736294268..d7b3be3987 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -1234,10 +1234,12 @@ > [% UNLESS patron %] > var PWD_STRONG_MSG = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers"); > var PWD_WEAK_MSG = _("Password must contain at least %s characters"); >+ var default_password_length = [% defaultCategory.effective_min_password_length | html %]; >+ var default_strong_password = [% defaultCategory.effective_require_strong_password | html %]; > $(document).ready(function() { > var setPwdMessage = function() { >- var require_strong = $('select#borrower_categorycode option:selected').data('pwdStrong'); >- var min_lenght = $('select#borrower_categorycode option:selected').data('pwdLength'); >+ var require_strong = $('select#borrower_categorycode option:selected').data('pwdStrong')||default_strong_password; >+ var min_lenght = $('select#borrower_categorycode option:selected').data('pwdLength')||default_password_length; > $('#password_alert').html((require_strong?PWD_STRONG_MSG:PWD_WEAK_MSG).format(min_lenght)); > }; > setPwdMessage(); >@@ -1246,6 +1248,6 @@ > [% END %] > //]]> > </script> >- [% PROCESS 'password_check.inc' new_password => 'borrower_password', category_selector => '#borrower_categorycode', RequireStrongPassword => patron.category.effective_require_strong_password, minPasswordLength => patron.category.effective_min_password_length %] >+ [% PROCESS 'password_check.inc' new_password => 'borrower_password', category_selector => '#borrower_categorycode', RequireStrongPassword => patron ? patron.category.effective_require_strong_password : defaultCategory.effective_require_strong_password, minPasswordLength => patron ? patron.category.effective_min_password_length : defaultCategory.effective_min_password_length %] > > [% END %] >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 6b7afc0175..a3f1ae61b8 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -93,12 +93,15 @@ if ( defined $min ) { > ); > } > >+my $defaultCategory = Koha::Patron::Categories->find(C4::Context->preference('PatronSelfRegistrationDefaultCategory')); >+ > $template->param( > action => $action, > hidden => GetHiddenFields( $mandatory, $action ), > mandatory => $mandatory, > libraries => \@libraries, > OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), >+ defaultCategory => $defaultCategory, > ); > > my $attributes = ParsePatronAttributes($borrowernumber,$cgi); >@@ -476,7 +479,7 @@ sub CheckForInvalidFields { > push( @invalidFields, "password_match" ); > } > if ( $borrower->{'password'} ) { >- my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $borrower->{password}, Koha::Patron::Categories->find($borrower->{categorycode}) ); >+ my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $borrower->{password}, Koha::Patron::Categories->find($borrower->{categorycode}||C4::Context->preference('PatronSelfRegistrationDefaultCategory')) ); > unless ( $is_valid ) { > push @invalidFields, 'password_too_short' if $error eq 'too_short'; > push @invalidFields, 'password_too_weak' if $error eq 'too_weak'; >-- >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 27148
:
114154
|
114161
|
114235
|
114290
|
114563
|
114564
|
114565