2 class PermissionsController < ApiController
3 authorize_resource :class => false
5 before_action :check_api_readable
6 before_action :setup_user_auth
7 before_action :set_request_formats
8 around_action :api_call_handle_error, :api_call_timeout
10 # External apps that use the api are able to query which permissions
11 # they have. This currently returns a list of permissions granted to the current user:
12 # * if authenticated via OAuth, this list will contain all permissions granted by the user to the access_token.
13 # * if authenticated via basic auth all permissions are granted, so the list will contain all permissions.
14 # * unauthenticated users have no permissions, so the list will be empty.
16 @permissions = if doorkeeper_token.present?
17 doorkeeper_token.scopes.map { |s| :"allow_#{s}" }
18 elsif current_token.present?
19 ClientApplication.all_permissions.select { |p| current_token.read_attribute(p) }
21 ClientApplication.all_permissions
26 respond_to do |format|