From c67067744ce45de2caec5e3df43f5ff021b9770d Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 4 Dec 2023 05:24:01 +0000 Subject: [PATCH] Bug 35445: Require OPAC user to confirm self-registration with button push This change requires the OPAC user to confirm self-registration with a button push when verifying registration using an emailed token. Test plan: 0. Apply the patch and koha-plack --reload kohadev 1. Set syspref PatronSelfRegistrationVerifyByEmail to "Don't require" 2. Create a patron using the self-registration on the OPAC 3. Note that no confirmation step is needed when self-registering 4. Set syspref PatronSelfRegistrationVerifyByEmail to "Require" 5. Create a patron using the self-registration on the OPAC 6. Look in message_queue to find the URL with the token to visit in the browser 7. Visit that URL 8. Note that the page says "Registration pending" and asks you to click a button labeled "Confirm" 9. Click the button labeled "Confirm" 10. Note that the self-registration is confirmed and details are shown on the page Signed-off-by: Martin Renvoize Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- .../modules/opac-registration-confirmation.tt | 18 +++++++++- opac/opac-memberentry.pl | 2 ++ opac/opac-registration-verify.pl | 34 ++++++++++++++++--- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt index 0bc8e13285..5a20e52350 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt @@ -16,7 +16,11 @@
[% WRAPPER breadcrumbs %] [% WRAPPER breadcrumb_item bc_active= 1 %] - Registration complete + [% IF ( ! confirmed ) %] + Registration pending + [% ELSE %] + Registration complete + [% END %] [% END %] [% END #/ WRAPPER breadcrumbs %] @@ -42,6 +46,17 @@
[% END %] + [% IF ( ! confirmed ) %] +
+

Registration pending

+

Click the button below to confirm registration.

+
+ + + +
+
+ [% ELSE %]

Registration complete!

@@ -80,6 +95,7 @@
[% END %]
+ [% END %]
diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index a0f5a3ace2..51f03fca19 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -263,6 +263,8 @@ if ( $action eq 'create' ) { $template->param( password_cleartext => $patron->plain_text_password ); $template->param( borrower => $patron->unblessed ); + $template->param( confirmed => 1 ); + # If 'AutoEmailNewUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. if ( C4::Context->preference("AutoEmailNewUser") ) { #look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index 60a004e18f..7acbd9d229 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -41,18 +41,41 @@ unless ( C4::Context->preference('PatronSelfRegistration') ) { } my $token = $cgi->param('token'); +my $op = $cgi->param('op'); +my $confirmed; +if ( $op && $op eq 'confirmed' ) { + $confirmed = 1; +} my $m = Koha::Patron::Modifications->find( { verification_token => $token } ); my ( $template, $borrowernumber, $cookie ); my ( $error_type, $error_info ); +my $rego_found; if ( - $m # The token exists and the email is unique if requested - and not( - C4::Context->preference('PatronSelfRegistrationEmailMustBeUnique') - and Koha::Patrons->search( { email => $m->email } )->count + $m # The token exists and the email is unique if requested + and not(C4::Context->preference('PatronSelfRegistrationEmailMustBeUnique') + and Koha::Patrons->search( { email => $m->email } )->count ) ) - ) +{ + $rego_found = 1; +} + +if ( $rego_found + and !$confirmed ) +{ + ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-registration-confirmation.tt", + type => "opac", + query => $cgi, + authnotrequired => C4::Context->preference("OpacPublic") ? 1 : 0, + } + ); + $template->param( "token" => $token ); +} +elsif ( $rego_found + and $confirmed ) { my $patron_attrs = $m->unblessed; $patron_attrs->{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($patron_attrs->{categorycode})); @@ -88,6 +111,7 @@ if ( authnotrequired => C4::Context->preference("OpacPublic") ? 1 : 0, } ); + $template->param( "confirmed" => 1 ); C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences'); $template->param( password_cleartext => $patron->plain_text_password ); -- 2.39.5