Bug 34893: Add checkpw change to REST API

This patch adds the checkpw return value change to the REST API
route for validating user identifiers and password.

Test plan:
0. Apply patch
1. prove t/db_dependent/api/v1/password_validation.t

Bonus points:
1. koha-plack --reload kohadev
2. Enable syspref RESTBasicAuth
3. curl -XPOST -H "Content-Type: application/json" \
-u <staff_userid>:<staff_password> \
-d '{"identifier":"<cardnumber>","password":"<password>"}' \
http://localhost:8081/api/v1/auth/password/validation
4. Validation doesn't fail. It gives you cardnumber, patron_id, userid

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
David Cook 2023-11-28 22:57:39 +00:00 committed by Katrin Fischer
parent c1b94fc011
commit 11e919cc19
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -71,7 +71,7 @@ sub validate {
my $password = $body->{password} // "";
return try {
my ( $status, $THE_cardnumber, $THE_userid ) = C4::Auth::checkpw( $identifier, $password );
my ( $status, $THE_cardnumber, $THE_userid, $patron ) = C4::Auth::checkpw( $identifier, $password );
unless ( $status && $status > 0 ) {
my $error_response = $status == -2 ? 'Password expired' : 'Validation failed';
return $c->render(
@ -80,8 +80,6 @@ sub validate {
);
}
my $patron = Koha::Patrons->find( { cardnumber => $THE_cardnumber } );
return $c->render(
status => 201,
openapi => {