Properly handle account deleted
Close #191 Also fix an issue with public events not being accessible when requested as another logged-in user. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
3a133b946f
commit
bff00dea21
@ -15,7 +15,7 @@
|
|||||||
<search-field />
|
<search-field />
|
||||||
</b-navbar-item>
|
</b-navbar-item>
|
||||||
|
|
||||||
<b-navbar-dropdown v-if="currentUser.isLoggedIn" right>
|
<b-navbar-dropdown v-if="currentActor.id && currentUser.isLoggedIn" right>
|
||||||
<template slot="label" v-if="currentActor" class="navbar-dropdown-profile">
|
<template slot="label" v-if="currentActor" class="navbar-dropdown-profile">
|
||||||
<figure class="image is-32x32" v-if="currentActor.avatar">
|
<figure class="image is-32x32" v-if="currentActor.avatar">
|
||||||
<img class="is-rounded" alt="avatarUrl" :src="currentActor.avatar.url">
|
<img class="is-rounded" alt="avatarUrl" :src="currentActor.avatar.url">
|
||||||
@ -97,6 +97,7 @@ import { RouteName } from '@/router';
|
|||||||
skip() {
|
skip() {
|
||||||
return this.currentUser.isLoggedIn === false;
|
return this.currentUser.isLoggedIn === false;
|
||||||
},
|
},
|
||||||
|
error({ graphQLErrors }) { this.handleErrors(graphQLErrors); },
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
query: 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() {
|
async logout() {
|
||||||
await logout(this.$apollo.provider.defaultClient);
|
await logout(this.$apollo.provider.defaultClient);
|
||||||
this.$buefy.notification.open({
|
this.$buefy.notification.open({
|
||||||
|
@ -31,11 +31,11 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
{:error, :events_max_limit_reached}
|
{:error, :events_max_limit_reached}
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_event(
|
defp find_private_event(
|
||||||
_parent,
|
_parent,
|
||||||
%{uuid: uuid},
|
%{uuid: uuid},
|
||||||
%{context: %{current_user: %User{id: user_id}}} = _resolution
|
%{context: %{current_user: %User{id: user_id}}} = _resolution
|
||||||
) do
|
) do
|
||||||
case {:has_event, Mobilizon.Events.get_own_event_by_uuid_with_preload(uuid, user_id)} do
|
case {:has_event, Mobilizon.Events.get_own_event_by_uuid_with_preload(uuid, user_id)} do
|
||||||
{:has_event, %Event{} = event} ->
|
{:has_event, %Event{} = event} ->
|
||||||
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
|
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
|
||||||
@ -45,13 +45,13 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
end
|
end
|
||||||
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
|
case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do
|
||||||
{:has_event, %Event{} = event} ->
|
{:has_event, %Event{} = event} ->
|
||||||
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
|
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
|
||||||
|
|
||||||
{:has_event, _} ->
|
{:has_event, _} ->
|
||||||
{:error, "Event with UUID #{uuid} not found"}
|
find_private_event(parent, args, resolution)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user