fix(front): properly handle error when approving app

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-08-10 11:55:50 +02:00
parent 2c8c332ad0
commit 086d208ee5
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -91,7 +91,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useHead } from "@vueuse/head"; import { useHead } from "@vueuse/head";
import { computed, ref } from "vue"; import { computed, inject, ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useMutation } from "@vue/apollo-composable"; import { useMutation } from "@vue/apollo-composable";
import { import {
@ -102,6 +102,7 @@ import RouteName from "@/router/name";
import { IApplication } from "@/types/application.model"; import { IApplication } from "@/types/application.model";
import { scope as oAuthScopes } from "./scopes"; import { scope as oAuthScopes } from "./scopes";
import AlertCircle from "vue-material-design-icons/AlertCircle.vue"; import AlertCircle from "vue-material-design-icons/AlertCircle.vue";
import { Notifier } from "@/plugins/notifier";
const { t } = useI18n({ useScope: "global" }); const { t } = useI18n({ useScope: "global" });
@ -123,23 +124,26 @@ const collapses = computed(() =>
.filter((localScope) => localScope) .filter((localScope) => localScope)
); );
const { mutate: authorizeMutation, onDone: onAuthorizeMutationDone } = const {
useMutation< mutate: authorizeMutation,
{ onDone: onAuthorizeMutationDone,
authorizeApplication: { onError: onAuthorizeMutationError,
code: string; } = useMutation<
state: string; {
clientId: string; authorizeApplication: {
scope: string; code: string;
}; state: string;
}, clientId: string;
{ scope: string;
applicationClientId: string; };
redirectURI: string; },
state?: string | null; {
scope?: string | null; applicationClientId: string;
} redirectURI: string;
>(AUTORIZE_APPLICATION); state?: string | null;
scope?: string | null;
}
>(AUTORIZE_APPLICATION);
const authorize = () => { const authorize = () => {
authorizeMutation({ authorizeMutation({
@ -209,6 +213,14 @@ onAuthorizeMutationDone(({ data }) => {
} }
}); });
const notifier = inject<Notifier>("notifier");
onAuthorizeMutationError(({ graphQLErrors }) => {
graphQLErrors.forEach(({ message }) => {
notifier?.error(message);
});
});
useHead({ useHead({
title: computed(() => t("Authorize application")), title: computed(() => t("Authorize application")),
}); });