Bug 32426: Changes for opac-registration-verify

Similar to changes in opac-memberentry.

Test plan:
Now also enable  PatronSelfRegistrationVerifyByEmail.
Make the same change in Patron again with return $self.
Restart all. Self register. Check your email.
Follow the link. Verify that you have a similar alert.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-01-19 12:01:42 +01:00 committed by Tomas Cohen Arazi
parent 5fd51573a5
commit 79fa6025e8
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 34 additions and 21 deletions

View file

@ -37,6 +37,13 @@
<h1>Registration invalid!</h1>
<p>There were problems processing your registration. Please contact your library for help.</p>
[% IF error_type OR error_info %]
[% IF error_type == 'Koha::Exceptions::Patron::InvalidUserid' %]
<p>Error: Userid is not valid</p>
[% ELSE %]
<p>Error [% error_type %]: [% error_info %]</p>
[% END %]
[% END %]
</div>
</div> <!-- /#registration-confirmation-error -->
</div> <!-- /.col-lg-10/12 -->

View file

@ -18,6 +18,7 @@
use Modern::Perl;
use CGI qw ( -utf8 );
use Try::Tiny;
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers );
@ -42,6 +43,7 @@ my $token = $cgi->param('token');
my $m = Koha::Patron::Modifications->find( { verification_token => $token } );
my ( $template, $borrowernumber, $cookie );
my ( $error_type, $error_info );
if (
$m # The token exists and the email is unique if requested
@ -51,15 +53,6 @@ if (
)
)
{
( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-registration-confirmation.tt",
type => "opac",
query => $cgi,
authnotrequired => 1,
}
);
my $patron_attrs = $m->unblessed;
$patron_attrs->{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($patron_attrs->{categorycode}));
my $consent_dt = delete $patron_attrs->{gdpr_proc_consent};
@ -68,9 +61,15 @@ if (
delete $patron_attrs->{verification_token};
delete $patron_attrs->{changed_fields};
delete $patron_attrs->{extended_attributes};
my $patron = Koha::Patron->new( $patron_attrs )->store;
Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt;
my $patron;
try {
$patron = Koha::Patron->new( $patron_attrs )->store;
Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $patron && $consent_dt;
} catch {
$error_type = ref($_);
$error_info = "$_";
};
if ($patron) {
if( $m->extended_attributes ){
@ -80,6 +79,14 @@ if (
} else {
$m->delete();
}
( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-registration-confirmation.tt",
type => "opac",
query => $cgi,
authnotrequired => 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 );
@ -132,17 +139,16 @@ if (
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-registration-confirmation.tt','opac',$cgi);
$template->param( news_lang => $news_lang );
}
}
else {
( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-registration-invalid.tt",
type => "opac",
query => $cgi,
authnotrequired => 1,
}
);
if( !$template ) { # Missing token, patron exception, etc.
( $template, $borrowernumber, $cookie ) = get_template_and_user({
template_name => "opac-registration-invalid.tt",
type => "opac",
query => $cgi,
authnotrequired => 1,
});
$template->param( error_type => $error_type, error_info => $error_info );
}
output_html_with_http_headers $cgi, $cookie, $template->output;