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

(-)a/C4/Auth_with_shibboleth.pm (-3 / +24 lines)
Lines 22-27 use warnings; Link Here
22
22
23
use C4::Debug;
23
use C4::Debug;
24
use C4::Context;
24
use C4::Context;
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 95-103 sub checkpw_shib { Link Here
95
        return ( 1, $retnumber, $userid );
97
        return ( 1, $retnumber, $userid );
96
    }
98
    }
97
99
98
    # If we reach this point, the user is not a valid koha user
100
    if ( $shib->{'autocreate'} ) {
99
    $debug and warn "User $userid is not a valid Koha user";
101
        return _autocreate( $dbh, $shib, $userid );
100
    return 0;
102
    } else {
103
        # If we reach this point, the user is not a valid koha user
104
        $debug and warn "User $userid is not a valid Koha user";
105
        return 0;
106
    }
107
}
108
109
sub _autocreate {
110
    my ( $dbh, $shib, $userid ) = @_;
111
112
    my %borrower = ( userid => $userid );
113
114
    while ( my ( $key, $entry ) = each %{$shib->{'mapping'}} ) {
115
        $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
116
    }
117
118
    %borrower = AddMember_Auto( %borrower );
119
    C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower{'borrowernumber'}, categorycode => $borrower{'categorycode'} } );
120
121
    return ( 1, $borrower{'cardnumber'}, $borrower{'userid'} );
101
}
122
}
102
123
103
1;
124
1;
(-)a/C4/Members.pm (-3 / +13 lines)
Lines 121-126 BEGIN { Link Here
121
    #Insert data
121
    #Insert data
122
    push @EXPORT, qw(
122
    push @EXPORT, qw(
123
        &AddMember
123
        &AddMember
124
	&AddMember_Auto
124
        &AddMember_Opac
125
        &AddMember_Opac
125
        &MoveMemberToDeleted
126
        &MoveMemberToDeleted
126
        &ExtendMemberSubscriptionTo
127
        &ExtendMemberSubscriptionTo
Lines 2432-2437 sub GetBorrowersWithEmail { Link Here
2432
    return @result;
2433
    return @result;
2433
}
2434
}
2434
2435
2436
sub AddMember_Auto {
2437
    my ( %borrower ) = @_;
2438
2439
    $borrower{'cardnumber'} ||= fixup_cardnumber();
2440
2441
    $borrower{'borrowernumber'} = AddMember(%borrower);
2442
2443
    return ( %borrower );
2444
}
2445
2435
sub AddMember_Opac {
2446
sub AddMember_Opac {
2436
    my ( %borrower ) = @_;
2447
    my ( %borrower ) = @_;
2437
2448
Lines 2444-2452 sub AddMember_Opac { Link Here
2444
2455
2445
    $borrower{'cardnumber'} = fixup_cardnumber();
2456
    $borrower{'cardnumber'} = fixup_cardnumber();
2446
2457
2447
    my $borrowernumber = AddMember(%borrower);
2458
    %borrower = AddMember_Auto(%borrower);
2448
2459
2449
    return ( $borrowernumber, $password );
2460
    return ( $borrower{'borrowernumber'}, $borrower{'password'} );
2450
}
2461
}
2451
2462
2452
=head2 AddEnrolmentFeeIfNeeded
2463
=head2 AddEnrolmentFeeIfNeeded
2453
- 

Return to bug 12026