Bugzilla – Attachment 153691 Details for
Bug 34313
Make password validation endpoint return patron IDs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34313: Add patron information in pass validation response
Bug-34313-Add-patron-information-in-pass-validatio.patch (text/plain), 2.89 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-07-19 20:35:49 UTC
(
hide
)
Description:
Bug 34313: Add patron information in pass validation response
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-07-19 20:35:49 UTC
Size:
2.89 KB
patch
obsolete
>From f294f22b8ef675d2901e7ccb59dcdf4bfe7b7868 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 19 Jul 2023 16:15:13 -0300 >Subject: [PATCH] Bug 34313: Add patron information in pass validation response > >This patch makes the password validation response return the following >patron attributes to the API consumer: > >* cardnumber >* userid > >This will give hints on what was used to validate in the fallback >bahvior the endpoint has. > >To test: >1. Apply the unit tests patch >2. Run: > $ ktd --shell > k$ prove t/db_dependent/api/v1/password_validation.t >=> FAIL: The endpoint doesn't return this valuable data >3. Apply this patch >4. Repeat 2 >=> SUCESS: Tests pass! We got the cardnumber and the userid! >5. Sign off :-D >--- > Koha/REST/V1/Auth/Password.pm | 16 ++++++++++++---- > api/v1/swagger/paths/auth.yaml | 15 ++++++++++++++- > 2 files changed, 26 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Auth/Password.pm b/Koha/REST/V1/Auth/Password.pm >index 3f421a7eddc..f4d2faaa10b 100644 >--- a/Koha/REST/V1/Auth/Password.pm >+++ b/Koha/REST/V1/Auth/Password.pm >@@ -65,7 +65,7 @@ sub validate { > my $password = $body->{password} // ""; > > return try { >- my ( $status, $cardnumber, $userid ) = C4::Auth::checkpw( $identifier, $password ); >+ my ( $status, $THE_cardnumber, $THE_userid ) = C4::Auth::checkpw( $identifier, $password ); > unless ($status) { > return $c->render( > status => 400, >@@ -73,9 +73,17 @@ sub validate { > ); > } > >- return $c->render( status => 204, openapi => '' ); >- } >- catch { >+ my $patron = Koha::Patrons->find( { cardnumber => $THE_cardnumber } ); >+ >+ return $c->render( >+ status => 201, >+ openapi => { >+ cardnumber => $patron->cardnumber, >+ patron_id => $patron->id, >+ userid => $patron->userid, >+ } >+ ); >+ } catch { > if ( blessed $_ and $_->isa('Koha::Exceptions::Password') ) { > return $c->render( > status => 400, >diff --git a/api/v1/swagger/paths/auth.yaml b/api/v1/swagger/paths/auth.yaml >index 3b61a220133..b9dee70cdca 100644 >--- a/api/v1/swagger/paths/auth.yaml >+++ b/api/v1/swagger/paths/auth.yaml >@@ -1091,8 +1091,21 @@ > produces: > - application/json > responses: >- "204": >+ "201": > description: Validation successful >+ schema: >+ type: object >+ properties: >+ cardnumber: >+ type: string >+ description: cardnumber for the validated patron >+ patron_id: >+ type: integer >+ description: Internal patron identifier >+ userid: >+ type: string >+ description: userid for the validated patron >+ additionalProperties: false > "400": > description: Bad request > schema: >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34313
:
153685
|
153686
|
153690
|
153691
|
153787
|
153788
|
154462
|
154463