A platform for community discussion. Free, open, simple.
FIX: Allowed URLs for API scopes added by plugins (#15662)
Osama Sayegh688be607c981
diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rbindex 0de8dd4ca8b..d2e685d1654 100644--- a/app/models/api_key_scope.rb+++ b/app/models/api_key_scope.rb@@ -101,7 +101,14 @@ class ApiKeyScope < ActiveRecord::Baseurls = []if actions.present?- Rails.application.routes.routes.each do |route|+ routes = Rails.application.routes.routes.to_a+ Rails::Engine.descendants.each do |engine|+ next if engine == Rails::Application # abstract engine, can't call routes on it+ next if engine == Discourse::Application # equiv. to Rails.application+ routes.concat(engine.routes.routes.to_a)+ end++ routes.each do |route|defaults = route.defaultsaction = "#{defaults[:controller].to_s}##{defaults[:action]}"path = route.path.spec.to_s.gsub(/\(\.:format\)/, '')