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:
@@ -66,10 +66,14 @@ import { type AuthToken } from '~/generated/graphql';
|
||||
import { cookieStorage } from '~/utils/cookie-storage';
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
import { loginTokenState } from '../states/loginTokenState';
|
||||
import { isAppEffectRedirectEnabledState } from '@/app/states/isAppEffectRedirectEnabledState';
|
||||
|
||||
export const useAuth = () => {
|
||||
const setTokenPair = useSetRecoilState(tokenPairState);
|
||||
const setLoginToken = useSetRecoilState(loginTokenState);
|
||||
const setIsAppEffectRedirectEnabled = useSetRecoilState(
|
||||
isAppEffectRedirectEnabledState,
|
||||
);
|
||||
|
||||
const { origin } = useOrigin();
|
||||
const { requestFreshCaptchaToken } = useRequestFreshCaptchaToken();
|
||||
@@ -317,13 +321,20 @@ export const useAuth = () => {
|
||||
async (authTokens: AuthTokenPair) => {
|
||||
handleSetAuthTokens(authTokens);
|
||||
|
||||
setIsAppEffectRedirectEnabled(false);
|
||||
|
||||
// TODO: We can't parallelize this yet because when loadCurrentUSer is loaded
|
||||
// then UserProvider updates its children and PrefetchDataProvider is then triggered
|
||||
// which requires the correct metadata to be loaded (not the mocks)
|
||||
await loadCurrentUser();
|
||||
await refreshObjectMetadataItems();
|
||||
},
|
||||
[loadCurrentUser, handleSetAuthTokens, refreshObjectMetadataItems],
|
||||
[
|
||||
loadCurrentUser,
|
||||
handleSetAuthTokens,
|
||||
refreshObjectMetadataItems,
|
||||
setIsAppEffectRedirectEnabled,
|
||||
],
|
||||
);
|
||||
|
||||
const handleGetAuthTokensFromLoginToken = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user