Bugzilla – Attachment 174230 Details for
Bug 25090
Moderate OPAC self registrations before a patron account is created
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25090: Redirect OPAC self reg verification email to the library
Bug-25090-Redirect-OPAC-self-reg-verification-emai.patch (text/plain), 17.79 KB, created by
Owen Leonard
on 2024-11-07 13:38:57 UTC
(
hide
)
Description:
Bug 25090: Redirect OPAC self reg verification email to the library
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2024-11-07 13:38:57 UTC
Size:
17.79 KB
patch
obsolete
>From 65d22db85e786c45599cae84cdbc149ac773fe4c Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleisha@catalyst.net.nz> >Date: Mon, 4 Nov 2024 02:19:35 +0000 >Subject: [PATCH] Bug 25090: Redirect OPAC self reg verification email to the > library > >This enhancement changes the PatronSelfRegistrationVerifyByEmail system >preference to have the following options: > >* don't require (same as 0 previously) >* patron verifies (same as 1 previously) >* library verifies, based on the EmailPatronRegistrations syspref > setting > >If the syspref is set to "based on the EmailPatronRegistrations" >setting, this allows the library to redirect the verification email so >that they can essentially moderate accounts that self-register via the >OPAC. > >This enhancement also introduces a new notice OPAC_REG_VERIFY_LIB which >includes the new account's details and the verification link. > >To test: > >1. Apply patches, install database updates, and restart services (if > using ktd, do `koha-upgrade-schema kohadev` then `restart_all`) >2. Go to the staff interface, Koha administration, system preferences. > Go to the OPAC tab and find the self-registration and modification > section. >3. By default, the PatronSelfRegistrationVerifyByEmail is set to "not > required". Change this to "must verify themselves via email". >4. Change EmailPatronRegistrations to anything other than "none" (we're > not specifically testing this functionality). >5. Confirm that PatronSelfRegistration is set to "Allow", as are other > required preferences (these should be set by default in ktd). > >6. Go to the OPAC in another window. You may be automatically logged in, > if so, log out. >7. On the homepage, click the "Create an account" link under the login > section. >8. Fill in the required fields and submit. > >9. In your commandline, go to the database and view the results from the > message_queue table (`koha-mysql kohadev` then `select * from > message_queue\G`) > >10. Confirm there is a queued message to the new account holder with a > verification link. Open the verification link in your browser (you > may need to swap out the OPACBaseURL if that isn't set correctly) >11. Confirm the account's registration. >12. Repeat step 9. Confirm there is a queued message to whoever you set > EmailPatronRegistrations to, confirming a new account was created. > >13. Go to your staff interface tab (you may need to log in again). >14. Go to the staff interface, Koha administration, system preferences. > Go to the OPAC tab and find the self-registration and modification > section. >15. Change PatronSelfRegistrationVerifyByEmail to "must be verified via > email sent to EmailPatronRegistrations" > >16. Repeat steps 6-9. >17. Confirm there is a queued message to the EmailPatronRegistrations > setting with a verification link. Open the verification link in your > browser (you may need to swap out the OPACBaseURL if that isn't set > correctly) >18. Confirm the account's registration. >19. Confirm the wording on the screen better reflects that you've > confirmed someone else's account and provides the login credentials > to send them. > >Sponsored-by: Mental Health Education & Resource Centre >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > Koha/Patron.pm | 21 ++-- > .../modules/opac-registration-confirmation.tt | 32 +++++-- > .../modules/opac-registration-email-sent.tt | 18 +++- > opac/opac-memberentry.pl | 95 +++++++++++++------ > 4 files changed, 114 insertions(+), 52 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index bc031f8bcf..b69a92d9ec 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2796,16 +2796,19 @@ sub notify_library_of_registration { > || C4::Context->preference('KohaAdminEmailAddress'); > } > >- my $message_id = C4::Letters::EnqueueLetter( >- { >- letter => $letter, >- borrowernumber => $self->borrowernumber, >- to_address => $to_address, >- message_transport_type => 'email' >+ unless ( C4::Context->preference("PatronSelfRegistrationVerifyByEmail") eq "library" ) { >+ # Only receive one of the OPAC_REG or OPAC_REG_VERIFY_LIB emails >+ my $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $self->borrowernumber, >+ to_address => $to_address, >+ message_transport_type => 'email' >+ } >+ ) or warn "can't enqueue letter $letter"; >+ if ($message_id) { >+ return 1; > } >- ) or warn "can't enqueue letter $letter"; >- if ( $message_id ) { >- return 1; > } > } > } >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 6fef58e72a..a743e6644f 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 >@@ -61,9 +61,18 @@ > <div id="registration-complete"> > <h1>Registration complete!</h1> > >- <p>You have successfully registered your new account.</p> >+ [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %] >+ <p>You have successfully registered this new account.</p> >+ [% ELSE %] >+ <p>You have successfully registered your new account.</p> >+ [% END %] >+ > [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %] >- <p>To log in, use the following credentials:</p> >+ [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %] >+ <p>Please securely provide the following credentials to the account holder so they can log in:</p> >+ [% ELSE %] >+ <p>To log in, use the following credentials:</p> >+ [% END %] > > <p id="patron-userid-p" class="registration-line"> > <span id="patron-userid-label" class="registration-label">Username:</span> >@@ -81,13 +90,16 @@ > </p> > [% END %] > >- <p id="patron-instructions"> >- [% IF borrower.category.effective_change_password %] >- <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in and change your password.</span> >- [% ELSE %] >- <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in.</span> >+ [% UNLESS Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %] >+ <p id="patron-instructions"> >+ [% IF borrower.category.effective_change_password %] >+ <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in and change your password.</span> >+ [% ELSE %] >+ <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in.</span> >+ [% END %] >+ </p> > [% END %] >- </p> >+ > [% END %] > > [% IF ( PatronSelfRegistrationAdditionalInstructions ) %] >@@ -110,13 +122,13 @@ > <fieldset class="brief"> > <legend>Log in to your account:</legend> > <label for="userid">Login:</label> >- [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %] >+ [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') && Koha.Preference('PatronSelfRegistrationVerifyByEmail') != "library" %] > <input class="form-control" type="text" id="userid" size="10" name="login_userid" value="[% borrower.userid | html %]" autocomplete="off" /> > [% ELSE %] > <input class="form-control" type="text" id="userid" size="10" name="login_userid" value="" autocomplete="off" /> > [% END %] > <label for="password">Password:</label> >- [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') %] >+ [% IF Koha.Preference('PatronSelfRegistrationPrefillForm') && Koha.Preference('PatronSelfRegistrationVerifyByEmail') != "library" %] > <input class="form-control" type="password" id="password" size="10" name="login_password" value="[% password_cleartext | html %]" autocomplete="off" /> > [% ELSE %] > <input class="form-control" type="password" id="password" size="10" name="login_password" value="" autocomplete="off" /> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt >index abbd92032a..771d91c7db 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-email-sent.tt >@@ -29,13 +29,21 @@ > <div class="col order-first order-md-first order-lg-2"> > [% END %] > <div id="registration-confirmation-pending" class="maincontent"> >- <h1>Please confirm your registration</h1> >- <div id="confirmation-pending" class="alert alert-info"> >+ [% IF Koha.Preference('PatronSelfRegistrationVerifyByEmail') == "library" %] >+ <h1>Your account is pending confirmation</h1> >+ <div id="confirmation-pending" class="alert alert-info"> > >- <p>A confirmation email will be sent shortly to the email address <strong>[% email | html %]</strong>.</p> >+ <p>An email has been sent to the library to confirm the activation of your account.</p> >+ </div> <!-- /#confirmation-pending --> >+ [% ELSE %] >+ <h1>Please confirm your registration</h1> >+ <div id="confirmation-pending" class="alert alert-info"> > >- <p>Your account will not be activated until you follow the link provided in the confirmation email.</p> >- </div> <!-- /#confirmation-pending --> >+ <p>A confirmation email will be sent shortly to the email address <strong>[% email | html %]</strong>.</p> >+ >+ <p>Your account will not be activated until you follow the link provided in the confirmation email.</p> >+ </div> <!-- /#confirmation-pending --> >+ [% END %] > </div> <!-- /#registration-confirmation-pending --> > </div> <!-- /.col/10 --> > </div> <!-- /.row --> >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index b671dde7c0..b11c3abb2a 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -177,11 +177,7 @@ if ( $op eq 'cud-create' ) { > die "Branchcode not allowed"; # They hack the form > } > else { >- if ( >- C4::Context->preference( >- 'PatronSelfRegistrationVerifyByEmail') >- ) >- { >+ if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') ne "off" ) { > ( $template, $borrowernumber, $cookie ) = get_template_and_user( > { > template_name => "opac-registration-email-sent.tt", >@@ -190,38 +186,81 @@ if ( $op eq 'cud-create' ) { > authnotrequired => 1, > } > ); >- $template->param( 'email' => $borrower{'email'} ); >+ $template->param( 'email' => $borrower{'email'} ) >+ if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') eq "patron" ); > >- my $verification_token = md5_hex( time().{}.rand().{}.$$ ); >+ my $verification_token = md5_hex( time() . {} . rand() . {} . $$ ); > while ( Koha::Patron::Modifications->search( { verification_token => $verification_token } )->count() ) { >- $verification_token = md5_hex( time().{}.rand().{}.$$ ); >+ $verification_token = md5_hex( time() . {} . rand() . {} . $$ ); > } > >- $borrower{password} = Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($borrower{categorycode})) unless $borrower{password}; >+ $borrower{password} = >+ Koha::AuthUtils::generate_password( Koha::Patron::Categories->find( $borrower{categorycode} ) ) >+ unless $borrower{password}; > $borrower{verification_token} = $verification_token; > > $borrower{extended_attributes} = to_json($attributes); > Koha::Patron::Modification->new( \%borrower )->store(); > >- #Send verification email >- my $letter = C4::Letters::GetPreparedLetter( >- module => 'members', >- letter_code => 'OPAC_REG_VERIFY', >- lang => 'default', # Patron does not have a preferred language defined yet >- tables => { >- borrower_modifications => $verification_token, >- }, >- ); >- >- my $message_id = C4::Letters::EnqueueLetter( >- { >- letter => $letter, >- message_transport_type => 'email', >- to_address => $borrower{'email'}, >- from_address => >- C4::Context->preference('KohaAdminEmailAddress'), >+ my $message_id; >+ >+ if ( C4::Context->preference('PatronSelfRegistrationVerifyByEmail') eq "library" ) { >+ >+ #Send verification email >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'members', >+ letter_code => 'OPAC_REG_VERIFY_LIB', >+ lang => 'default', # Patron does not have a preferred language defined yet >+ tables => { >+ 'borrower_modifications' => $verification_token, >+ }, >+ ); >+ >+ my $email_patron_registrations = C4::Context->preference('EmailPatronRegistrations'); >+ my $to_address; >+ if ( $email_patron_registrations eq "BranchEmailAddress" ) { >+ my $library = Koha::Libraries->find( $borrower{branchcode} ); >+ $to_address = $library->inbound_email_address; >+ } elsif ( $email_patron_registrations eq "KohaAdminEmailAddress" ) { >+ $to_address = C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); >+ } else { >+ $to_address = >+ C4::Context->preference('EmailAddressForPatronRegistrations') >+ || C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); > } >- ); >+ >+ $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ message_transport_type => 'email', >+ to_address => $to_address, >+ from_address => C4::Context->preference('KohaAdminEmailAddress'), >+ } >+ ); >+ >+ } else { >+ >+ #Send verification email >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'members', >+ letter_code => 'OPAC_REG_VERIFY', >+ lang => 'default', # Patron does not have a preferred language defined yet >+ tables => { >+ borrower_modifications => $verification_token, >+ }, >+ ); >+ >+ $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ message_transport_type => 'email', >+ to_address => $borrower{'email'}, >+ from_address => C4::Context->preference('KohaAdminEmailAddress'), >+ } >+ ); >+ } > C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; > } > else { >@@ -444,7 +483,7 @@ sub GetMandatoryFields { > if ( $op eq 'cud-create' || $op eq 'new' ) { > $mandatory_fields{'email'} = 1 > if C4::Context->preference( >- 'PatronSelfRegistrationVerifyByEmail'); >+ 'PatronSelfRegistrationVerifyByEmail') eq "patron"; > } > > return \%mandatory_fields; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25090
:
102845
|
103535
|
103536
|
104380
|
104381
|
104382
|
104383
|
104386
|
104994
|
104996
|
105319
|
112493
|
112494
|
112495
|
112496
|
112497
|
173894
|
173895
|
173896
|
173897
|
173898
|
173899
|
173962
|
173963
|
173964
|
174228
|
174229
| 174230