Skip to content

Commit

Permalink
feat(subdomain): remove lastAuthenticateWorkspace on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
AMoreaux committed Nov 7, 2024
1 parent 76438a7 commit 1866118
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -73,7 +73,7 @@ export const DefaultLayout = () => {
const windowsWidth = useScreenSize().width;
const showAuthModal = useShowAuthModal();

const [lastAuthenticateWorkspace] = useRecoilState(
const lastAuthenticateWorkspace = useRecoilValue(
lastAuthenticateWorkspaceState,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const UPDATE_WORKSPACE = gql`
displayName
logo
allowImpersonation
isPublicInviteLinkEnabled
isGoogleAuthEnabled
isMicrosoftAuthEnabled
isPasswordAuthEnabled
}
}
`;
4 changes: 2 additions & 2 deletions packages/twenty-front/src/utils/cookie-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/twenty-front/src/utils/recoil-effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1866118

Please sign in to comment.