FEATURE: Introduce API scopes for badges.

This commit is contained in:
Alan Guo Xiang Tan 2021-12-06 10:27:25 +08:00
parent f3508065a3
commit 44588255fc
3 changed files with 18 additions and 1 deletions

View File

@ -51,6 +51,15 @@ class ApiKeyScope < ActiveRecord::Base
},
email: {
receive_emails: { actions: %w[admin/email#handle_mail] }
},
badges: {
create: { actions: %w[admin/badges#create] },
show: { actions: %w[badges#show] },
update: { actions: %w[admin/badges#update] },
delete: { actions: %w[admin/badges#destroy] },
list_user_badges: { actions: %w[user_badges#username], params: %i[username] },
assign_badge_to_user: { actions: %w[user_badges#create], params: %i[username] },
revoke_badge_from_user: { actions: %w[user_badges#destroy] },
}
}

View File

@ -4219,6 +4219,14 @@ en:
list: Get a list of users.
email:
receive_emails: Combine this scope with the mail-receiver to process incoming emails.
badges:
create: Create a new badge.
show: Obtain information about a badge.
update: Update a badge.
delete: Delete a badge.
list_user_badges: List user badges.
assign_badge_to_user: Assign a badge to a user.
revoke_badge_from_user: Revoke a badge from a user.
web_hooks:
title: "Webhooks"

View File

@ -237,7 +237,7 @@ describe Admin::ApiController do
scopes = response.parsed_body['scopes']
expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts', 'uploads', 'global')
expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts', 'uploads', 'global', 'badges')
end
end
end