diff --git a/js/src/components/NavBar.vue b/js/src/components/NavBar.vue index 7b77a5fce..ef22d4b14 100644 --- a/js/src/components/NavBar.vue +++ b/js/src/components/NavBar.vue @@ -15,7 +15,7 @@ - + @@ -97,6 +97,7 @@ import { RouteName } from '@/router'; skip() { return this.currentUser.isLoggedIn === false; }, + error({ graphQLErrors }) { this.handleErrors(graphQLErrors); }, }, config: { query: CONFIG, @@ -135,6 +136,12 @@ export default class NavBar extends Vue { } } + async handleErrors(errors: GraphQLError) { + if (errors[0].message === 'You need to be logged-in to view your list of identities') { + await this.logout(); + } + } + async logout() { await logout(this.$apollo.provider.defaultClient); this.$buefy.notification.open({ diff --git a/lib/mobilizon_web/resolvers/event.ex b/lib/mobilizon_web/resolvers/event.ex index 5dc961fb2..97518cf04 100644 --- a/lib/mobilizon_web/resolvers/event.ex +++ b/lib/mobilizon_web/resolvers/event.ex @@ -31,11 +31,11 @@ defmodule MobilizonWeb.Resolvers.Event do {:error, :events_max_limit_reached} end - def find_event( - _parent, - %{uuid: uuid}, - %{context: %{current_user: %User{id: user_id}}} = _resolution - ) do + defp find_private_event( + _parent, + %{uuid: uuid}, + %{context: %{current_user: %User{id: user_id}}} = _resolution + ) do case {:has_event, Mobilizon.Events.get_own_event_by_uuid_with_preload(uuid, user_id)} do {:has_event, %Event{} = event} -> {:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))} @@ -45,13 +45,13 @@ defmodule MobilizonWeb.Resolvers.Event do end end - def find_event(_parent, %{uuid: uuid}, _resolution) do + def find_event(parent, %{uuid: uuid} = args, resolution) do case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do {:has_event, %Event{} = event} -> {:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))} {:has_event, _} -> - {:error, "Event with UUID #{uuid} not found"} + find_private_event(parent, args, resolution) end end