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

(-)a/C4/ILSDI/Services.pm (-14 / +10 lines)
Lines 313-340 the patron. Link Here
313
Parameters:
313
Parameters:
314
314
315
  - username (Required)
315
  - username (Required)
316
	user's login identifier
316
    user's login identifier (userid or cardnumber)
317
  - password (Required)
317
  - password (Required)
318
	user's password
318
    user's password
319
319
320
=cut
320
=cut
321
321
322
sub AuthenticatePatron {
322
sub AuthenticatePatron {
323
    my ($cgi) = @_;
323
    my ($cgi) = @_;
324
324
    my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $cgi->param('username'), $cgi->param('password') );
325
    # Check if borrower exists, using a C4::Auth function...
325
    if ( $status ) {
326
    unless( C4::Auth::checkpw( C4::Context->dbh, $cgi->param('username'), $cgi->param('password') ) ) {
326
        # Get the borrower
327
        my $borrower = GetMember( cardnumber => $cardnumber );
328
        my $patron->{'id'} = $borrower->{'borrowernumber'};
329
        return $patron;
330
    }
331
    else {
327
        return { code => 'PatronNotFound' };
332
        return { code => 'PatronNotFound' };
328
    }
333
    }
329
330
    # Get the borrower
331
    my $borrower = GetMember( userid => $cgi->param('username') );
332
333
    # Build the hashref
334
    my $patron->{'id'} = $borrower->{'borrowernumber'};
335
336
    # ... and return his ID
337
    return $patron;
338
}
334
}
339
335
340
=head2 GetPatronInfo
336
=head2 GetPatronInfo
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/ilsdi.tt (-1 / +1 lines)
Lines 388-394 Link Here
388
                <h4>Parameters</h4>
388
                <h4>Parameters</h4>
389
                <dl>
389
                <dl>
390
                    <dt><strong>username</strong> (Required)</dt>
390
                    <dt><strong>username</strong> (Required)</dt>
391
                    <dd>user's login identifier</dd>
391
                    <dd>user's login identifier (userid or cardnumber)</dd>
392
                    <dt><strong>password</strong> (Required)</dt>
392
                    <dt><strong>password</strong> (Required)</dt>
393
                    <dd>user's password</dd>
393
                    <dd>user's password</dd>
394
                </dl>
394
                </dl>
(-)a/t/db_dependent/ILSDI_Services.t (-3 lines)
Lines 72-78 my $borrower = GetMember( borrowernumber => $borrowernumber ); Link Here
72
    is($reply->{'id'}, $borrowernumber, "userid is not case sensitive - Patron authenticated");
72
    is($reply->{'id'}, $borrowernumber, "userid is not case sensitive - Patron authenticated");
73
    is($reply->{'code'}, undef, "Error code undef");     
73
    is($reply->{'code'}, undef, "Error code undef");     
74
74
75
TODO: { local: $TODO = "Can't use cardnumber for authentication with ILS-DI yet.";
76
    $query->param('username',$borrower->{'cardnumber'});
75
    $query->param('username',$borrower->{'cardnumber'});
77
    $reply = C4::ILSDI::Services::AuthenticatePatron($query);
76
    $reply = C4::ILSDI::Services::AuthenticatePatron($query);
78
    is($reply->{'id'}, $borrowernumber, "cardnumber and password - Patron authenticated");
77
    is($reply->{'id'}, $borrowernumber, "cardnumber and password - Patron authenticated");
Lines 88-94 TODO: { local: $TODO = "Can't use cardnumber for authentication with ILS-DI yet. Link Here
88
    $reply = C4::ILSDI::Services::AuthenticatePatron($query);
87
    $reply = C4::ILSDI::Services::AuthenticatePatron($query);
89
    is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound");
88
    is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound");
90
    is($reply->{'id'}, undef, "id undef");
89
    is($reply->{'id'}, undef, "id undef");
91
    }
92
90
93
}
91
}
94
92
95
- 

Return to bug 10667