Bug 28930

Summary: Cardnumber is lost if an invalid self registration form is submitted to the server, and the server side form validation fails
Product: Koha Reporter: Andreas Jonsson <andreas.jonsson>
Component: OPACAssignee: Andreas Jonsson <andreas.jonsson>
Status: CLOSED FIXED QA Contact: Joonas Kylmälä <joonas.kylmala>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, joonas.kylmala, kyle, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.05,20.11.11
Circulation function:
Attachments: Bug 28930: Keep cardnumber be editable after server side form validation fails during self registration.
Bug 28930: Keep cardnumber be editable after server side form validation fails during self registration.
Bug 28930: Keep cardnumber be editable after server side form validation fails during self registration.

Description Andreas Jonsson 2021-08-31 12:48:34 UTC
Cardnumber is lost if an invalid self registration form is submited to the server, and the server side form validation fails.

I believe the idea is that the cardnumber should not be editable when requesting modifications to the borrower's details in the OPAC.  But it would still make sense to keep the cardnumber field editable when correcting invalid form fields during self registration (also, see bug 17213).

So, a simple fix is to let the cardnumber be editable if action != 'edit'.

Test case

* Enable the system preference PatronSelfRegistration 
* Make sure  PatronSelfRegistrationBorrowerUnwantedField does not contain cardnumber.
* Set the system preference  GDPR_Policy to "Enforce".
* In the OPAC click "Log in to your account" and "Register here".
* Fill out the form with valid data, but make sure you leave the checkbox under "GDPR consent" unchecked.
* Submit the form
* You will get back the form with the error message "You have not filled out all required fields. Please fill in all missing fields and resubmit."
* Without patch: cardnumber is not editable, and there is no input element for borrower_cardnumber (so the cardnumber will be lost when resubmitting the form)
* With patch: cardnumber is editable.
Comment 1 Andreas Jonsson 2021-08-31 12:51:03 UTC
Created attachment 124278 [details] [review]
Bug 28930: Keep cardnumber be editable after server side form validation fails during self registration.
Comment 2 Owen Leonard 2021-09-01 11:38:43 UTC
Created attachment 124320 [details] [review]
Bug 28930: Keep cardnumber be editable after server side form validation fails during self registration.

Test plan:

- Enable the system preference PatronSelfRegistration
- Make sure  PatronSelfRegistrationBorrowerUnwantedField does not
  contain cardnumber.
- Set the system preference  GDPR_Policy to "Enforce".
- In the OPAC click "Log in to your account" and "Register here".
- Fill out the form with valid data, but make sure you leave the
  checkbox under "GDPR consent" unchecked.
- Submit the form
- You will get back the form with the error message "You have not filled
  out all required fields. Please fill in all missing fields and
  resubmit."
- Without patch: cardnumber is not editable, and there is no input
  element for borrower_cardnumber (so the cardnumber will be lost when
  resubmitting the form)
- With patch: cardnumber is editable.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 Joonas Kylmälä 2021-10-03 09:48:01 UTC
Created attachment 125665 [details] [review]
Bug 28930: Keep cardnumber be editable after server side form validation fails during self registration.

Test plan:

- Enable the system preference PatronSelfRegistration
- Make sure  PatronSelfRegistrationBorrowerUnwantedField does not
  contain cardnumber.
- Set the system preference  GDPR_Policy to "Enforce".
- In the OPAC click "Log in to your account" and "Register here".
- Fill out the form with valid data, but make sure you leave the
  checkbox under "GDPR consent" unchecked.
- Submit the form
- You will get back the form with the error message "You have not filled
  out all required fields. Please fill in all missing fields and
  resubmit."
- Without patch: cardnumber is not editable, and there is no input
  element for borrower_cardnumber (so the cardnumber will be lost when
  resubmitting the form)
- With patch: cardnumber is editable.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 4 Joonas Kylmälä 2021-10-03 09:50:05 UTC
Passing QA. This bug was actually "Fixed" already by bug 28934 which was pushed just recently but this fixes the situation where a librarian changes the Opac registration form mandatory values after the patron doing the registration has already loaded the registration page. So if GDPR option became mandatory whilst the patron was inputting the registration info this fixes it now :)
Comment 5 Jonathan Druart 2021-10-06 12:57:14 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 6 Kyle M Hall (khall) 2021-10-08 14:33:12 UTC
Pushed to 21.05.x for 21.05.05
Comment 7 Fridolin Somers 2021-10-21 06:03:00 UTC
Pushed to 20.11.x for 20.11.11
Comment 8 Victor Grousset/tuxayo 2021-10-26 01:00:47 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.