FIX: Adding a custom scope should not modify the original ones. (#12178)

Default scopes are stored inside a class variable, which shouldn't be modified when a custom scope is added. If this happens, we're no longer to remove the scope when the plugin is disabled.
This commit is contained in:
Roman Rizzi 2021-02-22 20:10:53 -03:00 committed by GitHub
parent 9a72876863
commit e485e95792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -59,10 +59,11 @@ class ApiKeyScope < ActiveRecord::Base
def scope_mappings
plugin_mappings = DiscoursePluginRegistry.api_key_scope_mappings
return default_mappings if plugin_mappings.empty?
default_mappings.deep_dup.tap do |mappings|
default_mappings.tap do |mappings|
plugin_mappings.each do |resource|
resource.each_value do |resource_actions|
resource_actions.each_value do |action_data|
action_data[:urls] = find_urls(action_data[:actions])