cartodb-4.42/lib/carto/oauth_provider/scopes/default_scope.rb

27 lines
726 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
module Carto
module OauthProvider
module Scopes
class DefaultScope < Scope
def initialize(type, service, category, description)
super("#{type}:#{service}", category, description)
@type = type
@service = service
end
def grant_section(grants)
section = grants.find { |i| i[:type] == @type }
section = section || { type: @type, @grant_key => [] }
section[@grant_key] ||= []
section
end
def add_to_api_key_grants(grants, _user = nil)
section = grant_section(grants)
section[@grant_key] << @service
ensure_grant_section(grants, section)
end
end
end
end
end