From 7efeb5829d530e368eae06d27ef595b84331ddd3 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Sun, 3 Jan 2016 12:41:59 -0800 Subject: [PATCH] fix syntax error --- app/controllers/application_controller.rb | 7 +++++++ app/controllers/related_tags_controller.rb | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c43ae964b..87a6f036a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,6 +21,13 @@ protected def enable_cors response.headers["Access-Control-Allow-Origin"] = "*" end + + def require_shared_key + unless params[:key] == Danbooru.config.shared_remote_key + render(text: "forbidden", status: 403) + return false + end + end def api_check if request.format.to_s =~ /\/json|\/xml/ || params[:controller] == "iqdb" diff --git a/app/controllers/related_tags_controller.rb b/app/controllers/related_tags_controller.rb index 1110920f3..0f5ec987b 100644 --- a/app/controllers/related_tags_controller.rb +++ b/app/controllers/related_tags_controller.rb @@ -1,5 +1,6 @@ class RelatedTagsController < ApplicationController respond_to :json + before_filter :require_shared_key, only: [:update] def show @query = RelatedTagQuery.new(params[:query].to_s.downcase, params[:category]) @@ -11,8 +12,6 @@ class RelatedTagsController < ApplicationController end def update - render(text: "forbidden", status: 403) && return false unless params[:key] == Danbooru.config.shared_remote_key - @tag = Tag.find_by_name(params[:name]) @tag.related_tags = params[:related_tags].scan(/\S+/).in_groups_of(2) @tag.related_tags_updated_at = Time.now