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

(-)a/C4/Auth_with_shibboleth.pm (-5 / +24 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use C4::Debug;
22
use C4::Debug;
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
use Koha::Database;
25
use C4::Members qw( AddMember_Auto );
26
use C4::Members::Messaging;
25
use Carp;
27
use Carp;
26
use CGI;
28
use CGI;
27
29
Lines 102-112 sub checkpw_shib { Link Here
102
        return ( 1, $borrower->get_column('cardnumber'), $borrower->get_column('userid') );
104
        return ( 1, $borrower->get_column('cardnumber'), $borrower->get_column('userid') );
103
    }
105
    }
104
106
105
    # If we reach this point, the user is not a valid koha user
107
    if ( $config->{'autocreate'} ) {
106
    $debug
108
        return _autocreate( $dbh, $config, $match );
107
      and warn
109
    } else {
108
      "User with $config->{matchpoint} of $match is not a valid Koha user";
110
        # If we reach this point, the user is not a valid koha user
109
    return 0;
111
        $debug and warn "User with $config->{matchpoint} of $match is not a valid Koha user";
112
        return 0;
113
    }
110
}
114
}
111
115
112
sub _get_uri {
116
sub _get_uri {
Lines 146-151 sub _get_shib_config { Link Here
146
    }
150
    }
147
}
151
}
148
152
153
sub _autocreate {
154
    my ( $dbh, $config, $match ) = @_;
155
156
    my %borrower = ( $config->{matchpoint} => $match );
157
158
    while ( my ( $key, $entry ) = each %{$config->{'mapping'}} ) {
159
        $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
160
    }
161
162
    %borrower = AddMember_Auto( %borrower );
163
    C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower{'borrowernumber'}, categorycode => $borrower{'categorycode'} } );
164
165
    return ( 1, $borrower{'cardnumber'}, $borrower{'userid'} );
166
}
167
149
1;
168
1;
150
__END__
169
__END__
151
170
(-)a/C4/Members.pm (-3 / +13 lines)
Lines 126-131 BEGIN { Link Here
126
    #Insert data
126
    #Insert data
127
    push @EXPORT, qw(
127
    push @EXPORT, qw(
128
        &AddMember
128
        &AddMember
129
	&AddMember_Auto
129
        &AddMember_Opac
130
        &AddMember_Opac
130
        &MoveMemberToDeleted
131
        &MoveMemberToDeleted
131
        &ExtendMemberSubscriptionTo
132
        &ExtendMemberSubscriptionTo
Lines 2523-2528 sub GetBorrowersWithEmail { Link Here
2523
    return @result;
2524
    return @result;
2524
}
2525
}
2525
2526
2527
sub AddMember_Auto {
2528
    my ( %borrower ) = @_;
2529
2530
    $borrower{'cardnumber'} ||= fixup_cardnumber();
2531
2532
    $borrower{'borrowernumber'} = AddMember(%borrower);
2533
2534
    return ( %borrower );
2535
}
2536
2526
sub AddMember_Opac {
2537
sub AddMember_Opac {
2527
    my ( %borrower ) = @_;
2538
    my ( %borrower ) = @_;
2528
2539
Lines 2535-2543 sub AddMember_Opac { Link Here
2535
2546
2536
    $borrower{'cardnumber'} = fixup_cardnumber();
2547
    $borrower{'cardnumber'} = fixup_cardnumber();
2537
2548
2538
    my $borrowernumber = AddMember(%borrower);
2549
    %borrower = AddMember_Auto(%borrower);
2539
2550
2540
    return ( $borrowernumber, $password );
2551
    return ( $borrower{'borrowernumber'}, $borrower{'password'} );
2541
}
2552
}
2542
2553
2543
=head2 AddEnrolmentFeeIfNeeded
2554
=head2 AddEnrolmentFeeIfNeeded
2544
- 

Return to bug 12026