about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-08-28 03:45:19 +0200
committerGitHub <noreply@github.com>2022-08-28 03:45:19 +0200
commitc57907737a35d05d4bb936acd662df6ce725456f (patch)
tree86425ed029a272cfa6aca63028d7d7f5858f5090 /app
parentc99c106ef08d44591d6b7802ea6f9914ea2842bd (diff)
Change search API to be accessible without being logged in (#18963)
But with the resolve option turned off
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v2/search_controller.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/app/controllers/api/v2/search_controller.rb b/app/controllers/api/v2/search_controller.rb
index a30560133..e384ecbaf 100644
--- a/app/controllers/api/v2/search_controller.rb
+++ b/app/controllers/api/v2/search_controller.rb
@@ -5,8 +5,7 @@ class Api::V2::SearchController < Api::BaseController
 
   RESULTS_LIMIT = 20
 
-  before_action -> { doorkeeper_authorize! :read, :'read:search' }
-  before_action :require_user!
+  before_action -> { authorize_if_got_token! :read, :'read:search' }
 
   def index
     @search = Search.new(search_results)
@@ -24,7 +23,7 @@ class Api::V2::SearchController < Api::BaseController
       params[:q],
       current_account,
       limit_param(RESULTS_LIMIT),
-      search_params.merge(resolve: truthy_param?(:resolve), exclude_unreviewed: truthy_param?(:exclude_unreviewed))
+      search_params.merge(resolve: user_signed_in? ? truthy_param?(:resolve) : false, exclude_unreviewed: truthy_param?(:exclude_unreviewed))
     )
   end