Skip to content

The open alternative to Salesforce, designed for AI.

fix(auth): handle error properly in loadCurrentUser (#9539)

Antoine Moreaux4ca03d00668b
diff --git a/packages/twenty-front/src/modules/auth/hooks/useAuth.ts b/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
index d583e815d8e..5646d5a2ff6 100644
--- a/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
@@ -177,6 +177,10 @@ export const useAuth = () => {
const loadCurrentUser = useCallback(async () => {
const currentUserResult = await getCurrentUser();
+ if (isDefined(currentUserResult.error)) {
+ throw new Error(currentUserResult.error.message);
+ }
+
const user = currentUserResult.data?.currentUser;
if (!user) {