View | Details | Raw Unified | Return to bug 20287
Collapse All | Expand All

(-)a/C4/Auth_with_shibboleth.pm (-4 / +4 lines)
Lines 23-29 use C4::Debug; Link Here
23
use C4::Context;
23
use C4::Context;
24
use Koha::AuthUtils qw(get_script_name);
24
use Koha::AuthUtils qw(get_script_name);
25
use Koha::Database;
25
use Koha::Database;
26
use C4::Members qw( AddMember_Auto );
26
use Koha::Patrons;
27
use C4::Members::Messaging;
27
use C4::Members::Messaging;
28
use Carp;
28
use Carp;
29
use CGI;
29
use CGI;
Lines 122-131 sub _autocreate { Link Here
122
        $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
122
        $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
123
    }
123
    }
124
124
125
    %borrower = AddMember_Auto( %borrower );
125
    my $patron = Koha::Patron->new( \%borrower )->store;
126
    C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower{'borrowernumber'}, categorycode => $borrower{'categorycode'} } );
126
    C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } );
127
127
128
    return ( 1, $borrower{'cardnumber'}, $borrower{'userid'} );
128
    return ( 1, $patron->cardnumber, $patron->userid );
129
}
129
}
130
130
131
sub _get_uri {
131
sub _get_uri {
(-)a/C4/Members.pm (-15 / +2 lines)
Lines 78-84 BEGIN { Link Here
78
78
79
    #Insert data
79
    #Insert data
80
    push @EXPORT, qw(
80
    push @EXPORT, qw(
81
    &AddMember_Auto
82
        &AddMember_Opac
81
        &AddMember_Opac
83
    );
82
    );
84
83
Lines 739-756 sub IssueSlip { Link Here
739
    );
738
    );
740
}
739
}
741
740
742
=head2 AddMember_Auto
743
744
=cut
745
746
sub AddMember_Auto {
747
    my ( %borrower ) = @_;
748
749
    my $patron = Koha::Patron->new(\%borrower)->store;
750
751
    return %{ $patron->unblessed };
752
}
753
754
=head2 AddMember_Opac
741
=head2 AddMember_Opac
755
742
756
=cut
743
=cut
Lines 767-775 sub AddMember_Opac { Link Here
767
        $borrower{'password'} = $password;
754
        $borrower{'password'} = $password;
768
    }
755
    }
769
756
770
    %borrower = AddMember_Auto(%borrower);
757
    my $patron = Koha::Patron->new(\%borrower)->store;
771
758
772
    return ( $borrower{'borrowernumber'}, $password );
759
    return ( $patron->borrowernumber, $password );
773
}
760
}
774
761
775
=head2 DeleteExpiredOpacRegistrations
762
=head2 DeleteExpiredOpacRegistrations
(-)a/opac/opac-memberentry.pl (-6 / +17 lines)
Lines 207-219 if ( $action eq 'create' ) { Link Here
207
            $template->param( OpacPasswordChange =>
207
            $template->param( OpacPasswordChange =>
208
                  C4::Context->preference('OpacPasswordChange') );
208
                  C4::Context->preference('OpacPasswordChange') );
209
209
210
            my ( $borrowernumber, $password ) = AddMember_Opac(%borrower);
210
            my $patron = Koha::Patron->new( \%borrower )->store;
211
            C4::Members::Attributes::SetBorrowerAttributes( $borrowernumber, $attributes );
211
            if ( $patron ) {
212
            C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if $borrowernumber && C4::Context->preference('EnhancedMessagingPreferences');
212
                C4::Members::Attributes::SetBorrowerAttributes( $patron->borrowernumber, $attributes );
213
                if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
214
                    C4::Form::MessagingPreferences::handle_form_action(
215
                        $cgi,
216
                        { borrowernumber => $patron->borrowernumber },
217
                        $template,
218
                        1,
219
                        C4::Context->preference('PatronSelfRegistrationDefaultCategory')
220
                    );
221
                }
213
222
214
            $template->param( password_cleartext => $password );
223
                $template->param( password_cleartext => $password );
215
            my $patron = Koha::Patrons->find( $borrowernumber );
224
                $template->param( borrower => $patron->unblessed );
216
            $template->param( borrower => $patron->unblessed );
225
            } else {
226
                # FIXME Handle possible errors here
227
            }
217
            $template->param(
228
            $template->param(
218
                PatronSelfRegistrationAdditionalInstructions =>
229
                PatronSelfRegistrationAdditionalInstructions =>
219
                  C4::Context->preference(
230
                  C4::Context->preference(
(-)a/t/db_dependent/Members.t (-13 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 51;
20
use Test::More tests => 50;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 386-402 $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; Link Here
386
my $hashed_up =  Koha::AuthUtils::hash_password("Nexus-6", $borrower->{password});
386
my $hashed_up =  Koha::AuthUtils::hash_password("Nexus-6", $borrower->{password});
387
is( $borrower->{password} eq $hashed_up, 1, 'Check password hash equals hash of submitted password' );
387
is( $borrower->{password} eq $hashed_up, 1, 'Check password hash equals hash of submitted password' );
388
388
389
subtest 'Trivial test for AddMember_Auto' => sub {
390
    plan tests => 3;
391
    my $library = $builder->build({ source => 'Branch' });
392
    my $category = $builder->build({ source => 'Category' });
393
    my %borr = AddMember_Auto( surname=> 'Dick3', firstname => 'Philip', branchcode => $library->{branchcode}, categorycode => $category->{categorycode}, password => '34567890' );
394
    ok( $borr{borrowernumber}, 'Borrower hash contains borrowernumber' );
395
    like( $borr{cardnumber}, qr/^\d+$/, 'Borrower hash contains cardnumber' );
396
    my $patron = Koha::Patrons->find( $borr{borrowernumber} );
397
    isnt( $patron, undef, 'Patron found' );
398
};
399
400
$schema->storage->txn_rollback;
389
$schema->storage->txn_rollback;
401
390
402
subtest 'Koha::Patron->store (invalid categorycode) tests' => sub {
391
subtest 'Koha::Patron->store (invalid categorycode) tests' => sub {
403
- 

Return to bug 20287