fix: login redirection to active objects (#15366)

Fixes - https://github.com/twentyhq/twenty/issues/15364

- Removed `activeNonSystemObjectMetadataItems` from the hook as it was
not necessary. Hook use `alphaSortedActiveNonSystemObjectMetadataItems`
now.
- Correctly check for read permissions.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Ranjeet Baraik
2025-10-30 22:01:26 +05:30
committed by GitHub
parent 51fdaf2731
commit 0cbd1e8ec5
12 changed files with 87 additions and 55 deletions
@@ -1,17 +1,21 @@
import { isAppEffectRedirectEnabledState } from '@/app/states/isAppEffectRedirectEnabledState';
import { useAuth } from '@/auth/hooks/useAuth';
import { isAppWaitingForFreshObjectMetadataState } from '@/object-metadata/states/isAppWaitingForFreshObjectMetadataState';
import { shouldAppBeLoadingState } from '@/object-metadata/states/shouldAppBeLoadingState';
import { useSetRecoilState } from 'recoil';
export const useImpersonationAuth = () => {
const { getAuthTokensFromLoginToken } = useAuth();
const setIsAppWaitingForFreshObjectMetadata = useSetRecoilState(
isAppWaitingForFreshObjectMetadataState,
const setShouldAppBeLoading = useSetRecoilState(shouldAppBeLoadingState);
const setIsAppEffectRedirectEnabled = useSetRecoilState(
isAppEffectRedirectEnabledState,
);
const executeImpersonationAuth = async (loginToken: string) => {
setIsAppWaitingForFreshObjectMetadata(true);
setShouldAppBeLoading(true);
setIsAppEffectRedirectEnabled(false);
await getAuthTokensFromLoginToken(loginToken);
setIsAppWaitingForFreshObjectMetadata(false);
setShouldAppBeLoading(false);
setIsAppEffectRedirectEnabled(true);
};
return { executeImpersonationAuth };