Fix search exposing events to unlogged users
Closes #892 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -26,7 +26,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Search do
|
||||
%{page: page, limit: limit} = args,
|
||||
%{context: context} = _resolution
|
||||
) do
|
||||
current_actor = Map.get(context, :current_actor, nil)
|
||||
current_actor = Map.get(context, :current_actor)
|
||||
current_actor_id = if current_actor, do: current_actor.id, else: nil
|
||||
args = Map.put(args, :current_actor_id, current_actor_id)
|
||||
Search.search_actors(args, page, limit, :Group)
|
||||
@@ -37,7 +37,13 @@ defmodule Mobilizon.GraphQL.Resolvers.Search do
|
||||
"""
|
||||
@spec search_events(any(), map(), Absinthe.Resolution.t()) ::
|
||||
{:ok, Page.t(Event.t())} | {:error, String.t()}
|
||||
def search_events(_parent, %{page: page, limit: limit} = args, _resolution) do
|
||||
def search_events(
|
||||
_parent,
|
||||
%{page: page, limit: limit} = args,
|
||||
%{context: context} = _resolution
|
||||
) do
|
||||
current_user = Map.get(context, :current_user)
|
||||
args = Map.put(args, :current_user, current_user)
|
||||
Search.search_events(args, page, limit)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user