Lines 40-58
Controller method that checks a patron's password
Link Here
|
40 |
|
40 |
|
41 |
sub validate { |
41 |
sub validate { |
42 |
my $c = shift->openapi->valid_input or return; |
42 |
my $c = shift->openapi->valid_input or return; |
43 |
my $body = $c->validation->param('body'); |
|
|
44 |
my $userid = $body->{userid} // ''; |
45 |
my $patron = Koha::Patrons->find({ userid => $userid }); |
46 |
|
43 |
|
47 |
unless ($patron) { |
44 |
my $body = $c->req->json; |
|
|
45 |
|
46 |
my $identifier = $body->{identifier}; |
47 |
|
48 |
unless ( defined $identifier ) { |
48 |
return $c->render( status => 400, openapi => { error => "Validation failed" } ); |
49 |
return $c->render( status => 400, openapi => { error => "Validation failed" } ); |
49 |
} |
50 |
} |
50 |
|
51 |
|
51 |
my $password = $body->{password} // ""; |
52 |
my $password = $body->{password} // ""; |
52 |
|
53 |
|
53 |
return try { |
54 |
return try { |
54 |
my ($status, $cardnumber, $userid) = C4::Auth::checkpw($patron->userid, $password ); |
55 |
my ( $status, $cardnumber, $userid ) = C4::Auth::checkpw( $identifier, $password ); |
55 |
unless ( $status ) { |
56 |
unless ($status) { |
56 |
return $c->render( |
57 |
return $c->render( |
57 |
status => 400, |
58 |
status => 400, |
58 |
openapi => { error => "Validation failed" } |
59 |
openapi => { error => "Validation failed" } |