Make /api/0.6/permissions work for OAuth 2 clients

This commit is contained in:
Tom Hughes 2021-06-27 00:38:16 +01:00
parent 1bc1905248
commit 608aafbf14
3 changed files with 19 additions and 3 deletions

View file

@ -12,7 +12,9 @@ module Api
# * if authenticated via basic auth all permissions are granted, so the list will contain all permissions.
# * unauthenticated users have no permissions, so the list will be empty.
def show
@permissions = if current_token.present?
@permissions = if doorkeeper_token.present?
doorkeeper_token.scopes.map { |s| :"allow_#{s}" }
elsif current_token.present?
ClientApplication.all_permissions.select { |p| current_token.read_attribute(p) }
elsif current_user
ClientApplication.all_permissions