|
Lines 18-23
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
|
|
21 |
use Try::Tiny; |
| 21 |
|
22 |
|
| 22 |
use C4::Auth qw( get_template_and_user ); |
23 |
use C4::Auth qw( get_template_and_user ); |
| 23 |
use C4::Output qw( output_html_with_http_headers ); |
24 |
use C4::Output qw( output_html_with_http_headers ); |
|
Lines 42-47
my $token = $cgi->param('token');
Link Here
|
| 42 |
my $m = Koha::Patron::Modifications->find( { verification_token => $token } ); |
43 |
my $m = Koha::Patron::Modifications->find( { verification_token => $token } ); |
| 43 |
|
44 |
|
| 44 |
my ( $template, $borrowernumber, $cookie ); |
45 |
my ( $template, $borrowernumber, $cookie ); |
|
|
46 |
my ( $error_type, $error_info ); |
| 45 |
|
47 |
|
| 46 |
if ( |
48 |
if ( |
| 47 |
$m # The token exists and the email is unique if requested |
49 |
$m # The token exists and the email is unique if requested |
|
Lines 51-65
if (
Link Here
|
| 51 |
) |
53 |
) |
| 52 |
) |
54 |
) |
| 53 |
{ |
55 |
{ |
| 54 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
|
|
| 55 |
{ |
| 56 |
template_name => "opac-registration-confirmation.tt", |
| 57 |
type => "opac", |
| 58 |
query => $cgi, |
| 59 |
authnotrequired => 1, |
| 60 |
} |
| 61 |
); |
| 62 |
|
| 63 |
my $patron_attrs = $m->unblessed; |
56 |
my $patron_attrs = $m->unblessed; |
| 64 |
$patron_attrs->{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($patron_attrs->{categorycode})); |
57 |
$patron_attrs->{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($patron_attrs->{categorycode})); |
| 65 |
my $consent_dt = delete $patron_attrs->{gdpr_proc_consent}; |
58 |
my $consent_dt = delete $patron_attrs->{gdpr_proc_consent}; |
|
Lines 68-76
if (
Link Here
|
| 68 |
delete $patron_attrs->{verification_token}; |
61 |
delete $patron_attrs->{verification_token}; |
| 69 |
delete $patron_attrs->{changed_fields}; |
62 |
delete $patron_attrs->{changed_fields}; |
| 70 |
delete $patron_attrs->{extended_attributes}; |
63 |
delete $patron_attrs->{extended_attributes}; |
| 71 |
my $patron = Koha::Patron->new( $patron_attrs )->store; |
|
|
| 72 |
|
64 |
|
| 73 |
Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $consent_dt; |
65 |
my $patron; |
|
|
66 |
try { |
| 67 |
$patron = Koha::Patron->new( $patron_attrs )->store; |
| 68 |
Koha::Patron::Consent->new({ borrowernumber => $patron->borrowernumber, type => 'GDPR_PROCESSING', given_on => $consent_dt })->store if $patron && $consent_dt; |
| 69 |
} catch { |
| 70 |
$error_type = ref($_); |
| 71 |
$error_info = "$_"; |
| 72 |
}; |
| 74 |
|
73 |
|
| 75 |
if ($patron) { |
74 |
if ($patron) { |
| 76 |
if( $m->extended_attributes ){ |
75 |
if( $m->extended_attributes ){ |
|
Lines 80-85
if (
Link Here
|
| 80 |
} else { |
79 |
} else { |
| 81 |
$m->delete(); |
80 |
$m->delete(); |
| 82 |
} |
81 |
} |
|
|
82 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
| 83 |
{ |
| 84 |
template_name => "opac-registration-confirmation.tt", |
| 85 |
type => "opac", |
| 86 |
query => $cgi, |
| 87 |
authnotrequired => 1, |
| 88 |
} |
| 89 |
); |
| 83 |
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences'); |
90 |
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences'); |
| 84 |
|
91 |
|
| 85 |
$template->param( password_cleartext => $patron->plain_text_password ); |
92 |
$template->param( password_cleartext => $patron->plain_text_password ); |
|
Lines 132-148
if (
Link Here
|
| 132 |
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-registration-confirmation.tt','opac',$cgi); |
139 |
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-registration-confirmation.tt','opac',$cgi); |
| 133 |
$template->param( news_lang => $news_lang ); |
140 |
$template->param( news_lang => $news_lang ); |
| 134 |
} |
141 |
} |
| 135 |
|
|
|
| 136 |
} |
142 |
} |
| 137 |
else { |
143 |
|
| 138 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
144 |
if( !$template ) { # Missing token, patron exception, etc. |
| 139 |
{ |
145 |
( $template, $borrowernumber, $cookie ) = get_template_and_user({ |
| 140 |
template_name => "opac-registration-invalid.tt", |
146 |
template_name => "opac-registration-invalid.tt", |
| 141 |
type => "opac", |
147 |
type => "opac", |
| 142 |
query => $cgi, |
148 |
query => $cgi, |
| 143 |
authnotrequired => 1, |
149 |
authnotrequired => 1, |
| 144 |
} |
150 |
}); |
| 145 |
); |
151 |
$template->param( error_type => $error_type, error_info => $error_info ); |
| 146 |
} |
152 |
} |
| 147 |
|
153 |
|
| 148 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
154 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
| 149 |
- |
|
|