From ce863325c373bd3570c84b98ab34d4908a94f025 Mon Sep 17 00:00:00 2001 From: Antoine Moreaux Date: Thu, 7 Nov 2024 18:05:04 +0100 Subject: [PATCH] feat(subdomain): remove lastAuthenticateWorkspace on logout --- .../src/modules/ui/layout/page/components/DefaultLayout.tsx | 4 ++-- .../modules/workspace/graphql/mutations/updateWorkspace.ts | 4 ++++ packages/twenty-front/src/utils/cookie-storage.ts | 4 ++-- packages/twenty-front/src/utils/recoil-effects.ts | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx index 91bf4910be48..ced934d83190 100644 --- a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx +++ b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx @@ -21,7 +21,7 @@ import { isTwentyHosting, } from '~/utils/workspace-url.helper'; import { lastAuthenticateWorkspaceState } from '@/auth/states/lastAuthenticateWorkspaceState'; -import { useRecoilState } from 'recoil'; +import { useRecoilValue } from 'recoil'; import { useEffect } from 'react'; const StyledLayout = styled.div` @@ -73,7 +73,7 @@ export const DefaultLayout = () => { const windowsWidth = useScreenSize().width; const showAuthModal = useShowAuthModal(); - const [lastAuthenticateWorkspace] = useRecoilState( + const lastAuthenticateWorkspace = useRecoilValue( lastAuthenticateWorkspaceState, ); diff --git a/packages/twenty-front/src/modules/workspace/graphql/mutations/updateWorkspace.ts b/packages/twenty-front/src/modules/workspace/graphql/mutations/updateWorkspace.ts index fd4efa797923..a8a97eecc3b6 100644 --- a/packages/twenty-front/src/modules/workspace/graphql/mutations/updateWorkspace.ts +++ b/packages/twenty-front/src/modules/workspace/graphql/mutations/updateWorkspace.ts @@ -9,6 +9,10 @@ export const UPDATE_WORKSPACE = gql` displayName logo allowImpersonation + isPublicInviteLinkEnabled + isGoogleAuthEnabled + isMicrosoftAuthEnabled + isPasswordAuthEnabled } } `; diff --git a/packages/twenty-front/src/utils/cookie-storage.ts b/packages/twenty-front/src/utils/cookie-storage.ts index 1261a209dc63..183d0da52f1f 100644 --- a/packages/twenty-front/src/utils/cookie-storage.ts +++ b/packages/twenty-front/src/utils/cookie-storage.ts @@ -16,9 +16,9 @@ class CookieStorage { Cookies.set(key, value, attributes); } - removeItem(key: string): void { + removeItem(key: string, attributes?: Cookies.CookieAttributes): void { this.keys.delete(key); - Cookies.remove(key); + Cookies.remove(key, attributes); } clear(): void { diff --git a/packages/twenty-front/src/utils/recoil-effects.ts b/packages/twenty-front/src/utils/recoil-effects.ts index e47a13737ab7..31937e38a968 100644 --- a/packages/twenty-front/src/utils/recoil-effects.ts +++ b/packages/twenty-front/src/utils/recoil-effects.ts @@ -40,11 +40,11 @@ export const cookieStorageEffect = onSet((newValue, _, isReset) => { if (!newValue) { - cookieStorage.removeItem(key); + cookieStorage.removeItem(key, attributes); return; } isReset - ? cookieStorage.removeItem(key) + ? cookieStorage.removeItem(key, attributes) : cookieStorage.setItem(key, JSON.stringify(newValue), { expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 7), ...attributes,