Make sure a person profile page returns 404

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-12 12:16:36 +02:00
parent ff51c5bd1e
commit cd5418825b
8 changed files with 57 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
import { PERSON_MEMBERSHIPS, CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
import { FETCH_GROUP } from "@/graphql/group";
import RouteName from "@/router/name";
import { Group, IActor, IGroup, IPerson, MemberRole } from "@/types/actor";
import { Component, Vue } from "vue-property-decorator";
@@ -16,6 +17,9 @@ import { Component, Vue } from "vue-property-decorator";
skip() {
return !this.$route.params.preferredUsername;
},
error({ graphQLErrors }) {
this.handleErrors(graphQLErrors);
},
},
person: {
query: PERSON_MEMBERSHIPS,
@@ -46,4 +50,13 @@ export default class GroupMixin extends Vue {
)
);
}
handleErrors(errors: any[]) {
if (
errors.some((error) => error.status_code === 404) ||
errors.some(({ message }) => message.includes("has invalid value $uuid"))
) {
this.$router.replace({ name: RouteName.PAGE_NOT_FOUND });
}
}
}