X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fopac-registration-verify.pl;h=3748f5c330a157cbf7c878bdb30f1ac942271545;hb=cfbc53bb22e6f4a851a2a7cd6ede891012951410;hp=5ceff2697801dc5d353cb6d22e7d203b58dc653c;hpb=3691bd8419ee9a481b95af525bc7e0c08f4c4640;p=koha.git diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index 5ceff26978..3748f5c330 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -23,6 +23,8 @@ use C4::Auth; use C4::Output; use C4::Members; use C4::Form::MessagingPreferences; +use Koha::AuthUtils; +use Koha::Patrons; use Koha::Patron::Modifications; my $cgi = new CGI; @@ -34,10 +36,18 @@ unless ( C4::Context->preference('PatronSelfRegistration') ) { } my $token = $cgi->param('token'); -my $m = Koha::Patron::Modifications->new( verification_token => $token ); +my $m = Koha::Patron::Modifications->find( { verification_token => $token } ); my ( $template, $borrowernumber, $cookie ); -if ( $m->Verify() ) { + +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 + ) + ) +{ ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "opac-registration-confirmation.tt", @@ -50,18 +60,18 @@ if ( $m->Verify() ) { $template->param( OpacPasswordChange => C4::Context->preference('OpacPasswordChange') ); - my $borrower = Koha::Patron::Modifications->GetModifications({ verification_token => $token }); + my $patron_attrs = $m->unblessed; + $patron_attrs->{password} ||= Koha::AuthUtils::generate_password; - my $password; - ( $borrowernumber, $password ) = AddMember_Opac(%$borrower); + $patron_attrs->{categorycode} ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); + my $patron = Koha::Patron->new( $patron_attrs )->store; - if ($borrowernumber) { - Koha::Patron::Modifications->DelModifications({ verification_token => $token }); - C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences'); + if ($patron) { + $m->delete(); + 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 => $password ); - $template->param( - borrower => GetMember( borrowernumber => $borrowernumber ) ); + $template->param( password_cleartext => $patron->plain_text_password ); + $template->param( borrower => $patron->unblessed ); $template->param( PatronSelfRegistrationAdditionalInstructions => C4::Context->preference(