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

(-)a/C4/Auth_with_shibboleth.pm (-5 / +24 lines)
Lines 23-28 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 );
27
use C4::Members::Messaging;
26
use Carp;
28
use Carp;
27
use CGI;
29
use CGI;
28
30
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 ( $shib->{'autocreate'} ) {
106
    $debug
108
        return _autocreate( $dbh, $shib, $userid );
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 $userid is not a valid Koha user";
112
        return 0;
113
    }
114
}
115
116
sub _autocreate {
117
    my ( $dbh, $shib, $userid ) = @_;
118
119
    my %borrower = ( userid => $userid );
120
121
    while ( my ( $key, $entry ) = each %{$shib->{'mapping'}} ) {
122
        $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
123
    }
124
125
    %borrower = AddMember_Auto( %borrower );
126
    C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower{'borrowernumber'}, categorycode => $borrower{'categorycode'} } );
127
128
    return ( 1, $borrower{'cardnumber'}, $borrower{'userid'} );
110
}
129
}
111
130
112
sub _get_uri {
131
sub _get_uri {
(-)a/C4/Members.pm (-3 / +17 lines)
Lines 88-93 BEGIN { Link Here
88
    #Insert data
88
    #Insert data
89
    push @EXPORT, qw(
89
    push @EXPORT, qw(
90
        &AddMember
90
        &AddMember
91
    &AddMember_Auto
91
        &AddMember_Opac
92
        &AddMember_Opac
92
    );
93
    );
93
94
Lines 1261-1266 sub GetBorrowersWithEmail { Link Here
1261
    return @result;
1262
    return @result;
1262
}
1263
}
1263
1264
1265
=head2 AddMember_Auto
1266
1267
=cut
1268
1269
sub AddMember_Auto {
1270
    my ( %borrower ) = @_;
1271
1272
    $borrower{'cardnumber'} ||= fixup_cardnumber();
1273
1274
    $borrower{'borrowernumber'} = AddMember(%borrower);
1275
1276
    return ( %borrower );
1277
}
1278
1264
=head2 AddMember_Opac
1279
=head2 AddMember_Opac
1265
1280
1266
=cut
1281
=cut
Lines 1278-1286 sub AddMember_Opac { Link Here
1278
1293
1279
    $borrower{'cardnumber'} = fixup_cardnumber( $borrower{'cardnumber'} );
1294
    $borrower{'cardnumber'} = fixup_cardnumber( $borrower{'cardnumber'} );
1280
1295
1281
    my $borrowernumber = AddMember(%borrower);
1296
    %borrower = AddMember_Auto(%borrower);
1282
1297
1283
    return ( $borrowernumber, $borrower{'password'} );
1298
    return ( $borrower{'borrowernumber'}, $borrower{'password'} );
1284
}
1299
}
1285
1300
1286
=head2 DeleteExpiredOpacRegistrations
1301
=head2 DeleteExpiredOpacRegistrations
1287
- 

Return to bug 12026