Skip to content

The open alternative to Salesforce, designed for AI.

Fix auth (#527)

Charles Bochet11d18cc269e8
diff --git a/front/src/modules/settings/components/SettingsNavbar.tsx b/front/src/modules/settings/components/SettingsNavbar.tsx
index a0ff6b60938..9a988a97da1 100644
--- a/front/src/modules/settings/components/SettingsNavbar.tsx
+++ b/front/src/modules/settings/components/SettingsNavbar.tsx
@@ -21,7 +21,6 @@ export function SettingsNavbar() {
const handleLogout = useCallback(() => {
logout();
- window.location.href = '/';
}, [logout]);
return (
diff --git a/front/src/pages/auth/CreateProfile.tsx b/front/src/pages/auth/CreateProfile.tsx
index 873000f2f70..3c310e4c811 100644
--- a/front/src/pages/auth/CreateProfile.tsx
+++ b/front/src/pages/auth/CreateProfile.tsx
@@ -78,6 +78,7 @@ export function CreateProfile() {
},
},
refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''],
+ awaitRefetchQueries: true,
});
if (errors || !data?.updateUser) {
diff --git a/front/src/pages/auth/CreateWorkspace.tsx b/front/src/pages/auth/CreateWorkspace.tsx
index 6bcea161f6b..76a4a7f9c8d 100644
--- a/front/src/pages/auth/CreateWorkspace.tsx
+++ b/front/src/pages/auth/CreateWorkspace.tsx
@@ -55,6 +55,7 @@ export function CreateWorkspace() {
},
},
refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''],
+ awaitRefetchQueries: true,
});
if (errors || !data?.updateWorkspace) {
diff --git a/front/src/providers/user/UserProvider.tsx b/front/src/providers/user/UserProvider.tsx
index 81c0648af71..e4ccfb9fe8a 100644
--- a/front/src/providers/user/UserProvider.tsx
+++ b/front/src/providers/user/UserProvider.tsx
@@ -1,20 +1,22 @@
-import { useEffect } from 'react';
+import { useEffect, useState } from 'react';
import { useRecoilState } from 'recoil';
-import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { currentUserState } from '@/auth/states/currentUserState';
import { useGetCurrentUserQuery } from '~/generated/graphql';
export function UserProvider({ children }: React.PropsWithChildren) {
- const [currentUser, setCurrentUser] = useRecoilState(currentUserState);
- const isLoggedIn = useIsLogged();
+ const [, setCurrentUser] = useRecoilState(currentUserState);
const { data, loading } = useGetCurrentUserQuery();
+ const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
+ if (!loading) {
+ setIsLoading(false);
+ }
if (data?.currentUser) {
setCurrentUser(data?.currentUser);
}
- }, [setCurrentUser, data]);
+ }, [setCurrentUser, data, isLoading, loading]);
- return loading || (isLoggedIn && !currentUser) ? <></> : <>{children}</>;
+ return isLoading ? <></> : <>{children}</>;
}