From e485e95792046513b1456d70c8bd5373c1c5baa0 Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Mon, 22 Feb 2021 20:10:53 -0300 Subject: [PATCH] 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. --- app/models/api_key_scope.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rb index 56443ac835e..35347851614 100644 --- a/app/models/api_key_scope.rb +++ b/app/models/api_key_scope.rb @@ -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])