Bug 7534: (QA follow-up) Use Koha.Preference template plugin to fetch the pref's...
[koha.git] / opac / opac-memberentry.pl
index 9cfcb4d..4eeacf0 100755 (executable)
@@ -169,7 +169,7 @@ if ( $action eq 'create' ) {
                 $verification_token = md5_hex( time().{}.rand().{}.$$ );
             }
 
-            $borrower{password}           = Koha::AuthUtils::generate_password unless $borrower{password};
+            $borrower{password}          = Koha::AuthUtils::generate_password unless $borrower{password};
             $borrower{verification_token} = $verification_token;
 
             Koha::Patron::Modification->new( \%borrower )->store();
@@ -207,6 +207,8 @@ if ( $action eq 'create' ) {
             $template->param( OpacPasswordChange =>
                   C4::Context->preference('OpacPasswordChange') );
 
+            $borrower{categorycode}     ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
+            $borrower{password}         ||= Koha::AuthUtils::generate_password;
             my $patron = Koha::Patron->new( \%borrower )->store;
             if ( $patron ) {
                 C4::Members::Attributes::SetBorrowerAttributes( $patron->borrowernumber, $attributes );
@@ -220,7 +222,7 @@ if ( $action eq 'create' ) {
                     );
                 }
 
-                $template->param( password_cleartext => $password );
+                $template->param( password_cleartext => $patron->plain_text_password );
                 $template->param( borrower => $patron->unblessed );
             } else {
                 # FIXME Handle possible errors here