@@ -, +, @@ hidden a valid patron category and finally add categorycode to PatronSelfRegistrationBorrowerUnwantedField => Password's info alert shows "Password must contain at least => 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 --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt | 8 +++++--- opac/opac-memberentry.pl | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ a/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 %] //]]> - [% 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 %] --- a/opac/opac-memberentry.pl +++ a/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'; --