fix(front): properly handle error when approving app
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
2c8c332ad0
commit
086d208ee5
|
@ -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")),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue