Bug 27626

Summary: Patron self-registration breaks if categorycode and password are hidden
Product: Koha Reporter: Owen Leonard <oleonard>
Component: OPACAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: andrewfh, fridolin.somers, jonathan.druart, martin.renvoize, victor
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27148
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.04,20.05.10,19.11.16
Bug Depends on:    
Bug Blocks: 27634    
Attachments: Bug 27626: Fix self registration if categorycode is hidden and PatronSelfRegistrationVerifyByEmail
Bug 27626: Fix self registration if categorycode is hidden and PatronSelfRegistrationVerifyByEmail
Bug 27626: Fix self registration if categorycode is hidden and PatronSelfRegistrationVerifyByEmail

Description Owen Leonard 2021-02-04 13:50:51 UTC
If categorycode is selected in PatronSelfRegistrationBorrowerUnwantedField, data about password length and password strength is not submitted, causing the submission to fail with an error.

[You must provide a patron's category to validate password's strength and length] at /usr/share/perl5/Exception/Class/Base.pm line 88
Comment 1 Owen Leonard 2021-02-04 14:35:25 UTC
More details: Apparently the problem only occurs if PatronSelfRegistrationVerifyByEmail is turned on.
Comment 2 Jonathan Druart 2021-02-04 16:42:32 UTC
Created attachment 116329 [details] [review]
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.
Comment 3 Jonathan Druart 2021-02-04 16:45:20 UTC
Is the self registration feature supposed to work if there is no default category defined (PatronSelfRegistrationDefaultCategory)?
The "register here" link is not displayed, but the opac-memberentry.pl is not returning a 404, and the code is trying (badly) to deal with this situation.
If the feature must be turned off if the default cat is not defined, then maybe we should force categorycode in PatronSelfRegistrationBorrowerUnwantedField, and always use the default when a new patron is self-registered.
Comment 4 Owen Leonard 2021-02-09 20:38:28 UTC
Created attachment 116617 [details] [review]
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 <oleonard@myacpl.org>
Comment 5 Katrin Fischer 2021-02-15 20:52:18 UTC
I tried to test this, but ran into bug 27710 and then into:

Invalid 'from' parameter: root@localhost at /usr/share/perl5/Exception/Class/Base.pm line 88

KohAdminEmailAdress is filled, but my system not set up to sent email. 

Any ideas?
Comment 6 Jonathan Druart 2021-02-16 07:37:28 UTC
try: root@example.org
Comment 7 Katrin Fischer 2021-02-16 08:41:15 UTC
Hm, I already tried root@localhost and katrin@something.de so both syntax. Is there some special magic about the one you suggested? And is KohaAdminEmailAddress the one it shoud go into?
Comment 8 Jonathan Druart 2021-02-16 09:28:19 UTC
(In reply to Katrin Fischer from comment #7)
> Hm, I already tried root@localhost and katrin@something.de so both syntax.
> Is there some special magic about the one you suggested? And is
> KohaAdminEmailAddress the one it shoud go into?

katrin@something.de should work, please try again.
Comment 9 Katrin Fischer 2021-02-17 19:14:04 UTC
I've set all the email prefs to katrin@something.de and it doesn't change the error message:

Invalid 'from' parameter: root@localhost at /usr/share/perl5/Exception/Class/Base.pm line 88

I believe it might be related to the SMTP configuration, but I am not sure how to set that up on a devbox.
Comment 10 Jonathan Druart 2021-02-18 10:13:58 UTC
Katrin, here is what I did:

% git checkout -b bug_27626 origin/master
% git bz apply 27626
% reset_all
1. PatronSelfRegistrationVerifyByEmail => require
2. PatronSelfRegistrationBorrowerUnwantedField => categorycode
3. KohaAdminEmailAddress => root@example.org
4. /cgi-bin/koha/opac-memberentry.pl
"A confirmation email will be sent shortly to the email address xxx@example.org."
Comment 11 Jonathan Druart 2021-02-18 10:14:33 UTC
(In reply to Katrin Fischer from comment #9)
> I've set all the email prefs to katrin@something.de and it doesn't change
> the error message:
> 
> Invalid 'from' parameter: root@localhost at
> /usr/share/perl5/Exception/Class/Base.pm line 88
> 
> I believe it might be related to the SMTP configuration, but I am not sure
> how to set that up on a devbox.

No it's not, the error you get is coming from KohaAdminEmailAddress.
Comment 12 Katrin Fischer 2021-02-18 10:45:22 UTC
(In reply to Jonathan Druart from comment #11)
> (In reply to Katrin Fischer from comment #9)
> > I've set all the email prefs to katrin@something.de and it doesn't change
> > the error message:
> > 
> > Invalid 'from' parameter: root@localhost at
> > /usr/share/perl5/Exception/Class/Base.pm line 88
> > 
> > I believe it might be related to the SMTP configuration, but I am not sure
> > how to set that up on a devbox.
> 
> No it's not, the error you get is coming from KohaAdminEmailAddress.

But my KohaAdminEmailAddress was not set to root@localhost - I tried it various times. Maybe someoen else has to take that one.
Comment 13 Martin Renvoize 2021-02-23 09:03:08 UTC
Created attachment 117177 [details] [review]
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 <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Martin Renvoize 2021-02-23 09:03:34 UTC
The patch works well for me and the caveats are livable.

Passing QA
Comment 15 Jonathan Druart 2021-02-23 12:22:02 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 16 Fridolin Somers 2021-02-25 09:31:32 UTC
Pushed to 20.11.x for 20.11.04
Comment 17 Andrew Fuerste-Henry 2021-03-04 21:39:46 UTC
Pushed to 20.05.x for 20.05.10
Comment 18 Victor Grousset/tuxayo 2021-03-18 21:17:33 UTC
Backported: Pushed to 19.11.x branch for 19.11.16