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

(-)a/Koha/REST/V1/Auth/Password.pm (-7 / +8 lines)
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" }
(-)a/api/v1/swagger/paths/auth.yaml (-5 / +11 lines)
Lines 1062-1079 Link Here
1062
    parameters:
1062
    parameters:
1063
      - name: body
1063
      - name: body
1064
        in: body
1064
        in: body
1065
        description: A JSON object containing username and password information
1065
        description: |
1066
          A JSON object containing a patron identifier and password information.
1067
          
1068
          The identifier will be used to match patrons on the database using the
1069
          following order:
1070
1071
          * userid
1072
          * cardnumber
1066
        schema:
1073
        schema:
1067
          type: object
1074
          type: object
1068
          properties:
1075
          properties:
1069
            userid:
1076
            identifier:
1070
              description: Username
1077
              description: A patron identifier (`userid` or `cardnumber`)
1071
              type: string
1078
              type: string
1072
            password:
1079
            password:
1073
              description: Password (plain text)
1080
              description: Password (plain text)
1074
              type: string
1081
              type: string
1075
          required:
1082
          required:
1076
            - userid
1083
            - identifier
1077
            - password
1084
            - password
1078
          additionalProperties: false
1085
          additionalProperties: false
1079
    produces:
1086
    produces:
1080
- 

Return to bug 32739