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

(-)a/Koha/REST/V1/UserPermissions.pm (+52 lines)
Line 0 Link Here
1
package Koha::REST::V1::UserPermissions;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Try::Tiny qw( catch try );
23
24
use Koha::Auth::Permissions;
25
26
use C4::Auth;
27
28
=head1 API
29
30
=head2 Methods
31
32
=head3 get
33
34
=cut
35
36
sub get {
37
    my $c = shift->openapi->valid_input or return;
38
39
    return try {
40
        my $patron = $c->stash('koha.user');
41
42
        my $userflags = C4::Auth::getuserflags($patron->flags, $patron->id);
43
44
        my $permissions = Koha::Auth::Permissions->get_authz_from_flags({ flags => $userflags });
45
46
        return $c->render( status => 200, openapi => { permissions => $permissions }, );
47
    } catch {
48
        $c->unhandled_exception($_);
49
    };
50
}
51
52
1;
(-)a/api/v1/swagger/definitions/user_permission.yaml (+7 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  permissions:
5
    type: object
6
    description: the permissions object for the user
7
additionalProperties: false
(-)a/api/v1/swagger/paths/user_permissions.yaml (+49 lines)
Line 0 Link Here
1
---
2
/user_permissions:
3
  get:
4
    x-mojo-to: UserPermissions#get
5
    operationId: getUserPermissions
6
    description: This resource returns the permissions for the user attached to the request
7
    summary: List of permissions and subpermissions
8
    tags:
9
      - permissions
10
    parameters:
11
      - $ref: "../swagger.yaml#/parameters/match"
12
      - $ref: "../swagger.yaml#/parameters/order_by"
13
      - $ref: "../swagger.yaml#/parameters/page"
14
      - $ref: "../swagger.yaml#/parameters/per_page"
15
      - $ref: "../swagger.yaml#/parameters/q_param"
16
      - $ref: "../swagger.yaml#/parameters/q_body"
17
    produces:
18
      - application/json
19
    responses:
20
      "200":
21
        description: A list of permissions
22
        schema:
23
          type: object
24
          $ref: "../swagger.yaml#/definitions/user_permission"
25
      "400":
26
        description: |
27
          Bad request. Possible `error_code` attribute values:
28
29
            * `invalid_query`
30
        schema:
31
          $ref: "../swagger.yaml#/definitions/error"
32
      "403":
33
        description: Access forbidden
34
        schema:
35
          $ref: "../swagger.yaml#/definitions/error"
36
      "500":
37
        description: |
38
          Internal server error. Possible `error_code` attribute values:
39
40
          * `internal_server_error`
41
        schema:
42
          $ref: "../swagger.yaml#/definitions/error"
43
      "503":
44
        description: Under maintenance
45
        schema:
46
          $ref: "../swagger.yaml#/definitions/error"
47
    x-koha-authorization:
48
      permissions:
49
        catalogue: 1
(-)a/api/v1/swagger/swagger.yaml (+4 lines)
Lines 182-187 definitions: Link Here
182
    $ref: ./definitions/ticket_update.yaml
182
    $ref: ./definitions/ticket_update.yaml
183
  transfer_limit:
183
  transfer_limit:
184
    $ref: ./definitions/transfer_limit.yaml
184
    $ref: ./definitions/transfer_limit.yaml
185
  user_permission:
186
    $ref: ./definitions/user_permission.yaml
185
  vendor:
187
  vendor:
186
    $ref: ./definitions/vendor.yaml
188
    $ref: ./definitions/vendor.yaml
187
  vendor_issue:
189
  vendor_issue:
Lines 569-574 paths: Link Here
569
    $ref: ./paths/transfer_limits.yaml#/~1transfer_limits~1batch
571
    $ref: ./paths/transfer_limits.yaml#/~1transfer_limits~1batch
570
  "/transfer_limits/{limit_id}":
572
  "/transfer_limits/{limit_id}":
571
    $ref: "./paths/transfer_limits.yaml#/~1transfer_limits~1{limit_id}"
573
    $ref: "./paths/transfer_limits.yaml#/~1transfer_limits~1{limit_id}"
574
  "/user_permissions":
575
    $ref: "./paths/user_permissions.yaml#/~1user_permissions"
572
parameters:
576
parameters:
573
  advancededitormacro_id_pp:
577
  advancededitormacro_id_pp:
574
    description: Advanced editor macro internal identifier
578
    description: Advanced editor macro internal identifier
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js (-1 / +9 lines)
Lines 15-20 export class PatronAPIClient extends HttpClient { Link Here
15
                }),
15
                }),
16
        };
16
        };
17
    }
17
    }
18
19
    get userPermissions() {
20
        return {
21
            get: () =>
22
                this.get({
23
                    endpoint: "user_permissions",
24
                }),
25
        };
26
    }
18
}
27
}
19
28
20
export default PatronAPIClient;
29
export default PatronAPIClient;
21
- 

Return to bug 38930