From 4dac16fd363cb5fa84c5e8246be42533afbd73bc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 4 Feb 2021 17:37:26 +0100 Subject: [PATCH] Bug 27626: Fix self registration if categorycode is hidden and PatronSelfRegistrationVerifyByEmail If categorycode is selected in PatronSelfRegistrationBorrowerUnwantedField and PatronSelfRegistrationVerifyByEmail is turned on, the patron self registration fails with [You must provide a patron's category to validate password's strength and length] at /usr/share/perl5/Exception/Class/Base.pm line 88 Test plan: 0. Select categorycode in PatronSelfRegistrationBorrowerUnwantedField and turn on PatronSelfRegistrationVerifyByEmail 1. Self register a patron 2. Confirm that it works as expected with this patch applied. Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 74ae74d5faec9a4ba4fbf573b4a81b1274402773) Signed-off-by: Fridolin Somers (cherry picked from commit 2b021df3e2630d98ed6a72f32d3e7d63c8159aa6) Signed-off-by: Andrew Fuerste-Henry --- opac/opac-memberentry.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index e9d7758cb7..cfadb300a3 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -120,6 +120,7 @@ if ( $action eq 'create' ) { my %borrower = ParseCgiForBorrower($cgi); %borrower = DelEmptyFields(%borrower); + $borrower{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action ); my $invalidformfields = CheckForInvalidFields(\%borrower); @@ -215,8 +216,7 @@ if ( $action eq 'create' ) { } ); - $borrower{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); - $borrower{password} ||= Koha::AuthUtils::generate_password; + $borrower{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($borrower{categorycode})); my $consent_dt = delete $borrower{gdpr_proc_consent}; my $patron = Koha::Patron->new( \%borrower )->store; Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt; -- 2.39.5