fix(auth): small front fixes in 3rd-party auth provider callback
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
28c4ae2e48
commit
bde7206a1c
|
@ -80,7 +80,7 @@ export function registerAccount() {
|
||||||
) => {
|
) => {
|
||||||
if (context?.userAlreadyActivated) {
|
if (context?.userAlreadyActivated) {
|
||||||
const currentUserData = store.readQuery<{
|
const currentUserData = store.readQuery<{
|
||||||
loggedUser: Pick<ICurrentUser, "actors">;
|
loggedUser: Pick<ICurrentUser, "actors" | "id">;
|
||||||
}>({
|
}>({
|
||||||
query: IDENTITIES,
|
query: IDENTITIES,
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,10 @@ const userRole = getValueFromMeta("auth-user-role") as ICurrentUserRole;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { onDone, mutate } = useMutation<
|
const {
|
||||||
|
onDone: onUpdateCurrentUserClientDone,
|
||||||
|
mutate: updateCurrentUserClient,
|
||||||
|
} = useMutation<
|
||||||
{ updateCurrentUser: ICurrentUser },
|
{ updateCurrentUser: ICurrentUser },
|
||||||
{ id: string; email: string; isLoggedIn: boolean; role: ICurrentUserRole }
|
{ id: string; email: string; isLoggedIn: boolean; role: ICurrentUserRole }
|
||||||
>(UPDATE_CURRENT_USER_CLIENT);
|
>(UPDATE_CURRENT_USER_CLIENT);
|
||||||
|
@ -45,16 +48,19 @@ const { onResult: onLoggedUserResult, load: loadUser } = useLazyQuery<{
|
||||||
loggedUser: IUser;
|
loggedUser: IUser;
|
||||||
}>(LOGGED_USER);
|
}>(LOGGED_USER);
|
||||||
|
|
||||||
onDone(async () => {
|
onUpdateCurrentUserClientDone(async () => {
|
||||||
loadUser();
|
loadUser();
|
||||||
onLoggedUserResult(async ({ data: { loggedUser } }) => {
|
});
|
||||||
if (loggedUser.defaultActor) {
|
|
||||||
await changeIdentity(loggedUser.defaultActor);
|
onLoggedUserResult(async (result) => {
|
||||||
await router.push({ name: RouteName.HOME });
|
if (result.loading) return;
|
||||||
} else {
|
const loggedUser = result.data.loggedUser;
|
||||||
// No need to push to REGISTER_PROFILE, the navbar will do it for us
|
if (loggedUser.defaultActor) {
|
||||||
}
|
await changeIdentity(loggedUser.defaultActor);
|
||||||
});
|
await router.push({ name: RouteName.HOME });
|
||||||
|
} else {
|
||||||
|
// No need to push to REGISTER_PROFILE, the navbar will do it for us
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -67,13 +73,15 @@ onMounted(async () => {
|
||||||
email: userEmail,
|
email: userEmail,
|
||||||
role: userRole,
|
role: userRole,
|
||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
|
defaultActor: undefined,
|
||||||
|
actors: [],
|
||||||
},
|
},
|
||||||
accessToken,
|
accessToken,
|
||||||
refreshToken,
|
refreshToken,
|
||||||
};
|
};
|
||||||
saveUserData(login);
|
saveUserData(login);
|
||||||
|
|
||||||
mutate({
|
updateCurrentUserClient({
|
||||||
id: userId,
|
id: userId,
|
||||||
email: userEmail,
|
email: userEmail,
|
||||||
isLoggedIn: true,
|
isLoggedIn: true,
|
||||||
|
|
Loading…
Reference in a new issue