Fix logging from 3rd-party auth provider
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
1854063f09
commit
3d99a41104
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<p>{{ t("Redirecting in progress…") }}</p>
|
<p>{{ t("Redirecting in progress…") }}</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ICurrentUserRole } from "@/types/enums";
|
import { ICurrentUserRole } from "@/types/enums";
|
||||||
import { UPDATE_CURRENT_USER_CLIENT, LOGGED_USER } from "../../graphql/user";
|
import { UPDATE_CURRENT_USER_CLIENT, LOGGED_USER } from "../../graphql/user";
|
||||||
@ -9,10 +10,10 @@ import { saveUserData } from "../../utils/auth";
|
|||||||
import { changeIdentity } from "../../utils/identity";
|
import { changeIdentity } from "../../utils/identity";
|
||||||
import { ICurrentUser, IUser } from "../../types/current-user.model";
|
import { ICurrentUser, IUser } from "../../types/current-user.model";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useMutation, useQuery } from "@vue/apollo-composable";
|
import { useLazyQuery, useMutation } from "@vue/apollo-composable";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useHead } from "@vueuse/head";
|
import { useHead } from "@vueuse/head";
|
||||||
import { computed } from "vue";
|
import { computed, onMounted } from "vue";
|
||||||
|
|
||||||
const { t } = useI18n({ useScope: "global" });
|
const { t } = useI18n({ useScope: "global" });
|
||||||
useHead({
|
useHead({
|
||||||
@ -35,15 +36,17 @@ const userRole = getValueFromMeta("auth-user-role") as ICurrentUserRole;
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { onDone, mutate } = useMutation<{ updateCurrentUser: ICurrentUser }>(
|
const { onDone, mutate } = useMutation<
|
||||||
UPDATE_CURRENT_USER_CLIENT
|
{ updateCurrentUser: ICurrentUser },
|
||||||
);
|
{ id: string; email: string; isLoggedIn: boolean; role: ICurrentUserRole }
|
||||||
|
>(UPDATE_CURRENT_USER_CLIENT);
|
||||||
|
|
||||||
onDone(() => {
|
const { onResult: onLoggedUserResult, load: loadUser } = useLazyQuery<{
|
||||||
const { onResult: onLoggedUserResult } = useQuery<{ loggedUser: IUser }>(
|
loggedUser: IUser;
|
||||||
LOGGED_USER
|
}>(LOGGED_USER);
|
||||||
);
|
|
||||||
|
|
||||||
|
onDone(async () => {
|
||||||
|
loadUser();
|
||||||
onLoggedUserResult(async ({ data: { loggedUser } }) => {
|
onLoggedUserResult(async ({ data: { loggedUser } }) => {
|
||||||
if (loggedUser.defaultActor) {
|
if (loggedUser.defaultActor) {
|
||||||
await changeIdentity(loggedUser.defaultActor);
|
await changeIdentity(loggedUser.defaultActor);
|
||||||
@ -54,9 +57,10 @@ onDone(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(userId && userEmail && userRole && accessToken && refreshToken)) {
|
onMounted(async () => {
|
||||||
|
if (!(userId && userEmail && userRole && accessToken && refreshToken)) {
|
||||||
await router.push("/");
|
await router.push("/");
|
||||||
} else {
|
} else {
|
||||||
const login = {
|
const login = {
|
||||||
user: {
|
user: {
|
||||||
id: userId,
|
id: userId,
|
||||||
@ -75,5 +79,6 @@ if (!(userId && userEmail && userRole && accessToken && refreshToken)) {
|
|||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
role: userRole,
|
role: userRole,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user