Enforce system wide sso providers (#9058)
We have recently introduced the possibility to specify workspace specific auth providers. I'm: - introducing system wide auth providers (provided by clientConfig) - making sure workspace specific auth providers belong to system wide auth providers set
This commit is contained in:
@ -7,14 +7,14 @@ import { RecoilRoot, useRecoilValue } from 'recoil';
|
||||
import { iconsState } from 'twenty-ui';
|
||||
|
||||
import { useAuth } from '@/auth/hooks/useAuth';
|
||||
import { authProvidersState } from '@/client-config/states/authProvidersState';
|
||||
import { billingState } from '@/client-config/states/billingState';
|
||||
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
|
||||
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState';
|
||||
import { supportChatState } from '@/client-config/states/supportChatState';
|
||||
import { workspaceAuthProvidersState } from '@/workspace/states/workspaceAuthProvidersState';
|
||||
|
||||
import { email, mocks, password, results, token } from '../__mocks__/useAuth';
|
||||
import { isMultiWorkspaceEnabledState } from '@/client-config/states/isMultiWorkspaceEnabledState';
|
||||
import { email, mocks, password, results, token } from '../__mocks__/useAuth';
|
||||
|
||||
const Wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<MockedProvider mocks={mocks} addTypename={false}>
|
||||
@ -77,7 +77,9 @@ describe('useAuth', () => {
|
||||
() => {
|
||||
const client = useApolloClient();
|
||||
const icons = useRecoilValue(iconsState);
|
||||
const authProviders = useRecoilValue(authProvidersState);
|
||||
const workspaceAuthProviders = useRecoilValue(
|
||||
workspaceAuthProvidersState,
|
||||
);
|
||||
const billing = useRecoilValue(billingState);
|
||||
const isDeveloperDefaultSignInPrefilled = useRecoilValue(
|
||||
isDeveloperDefaultSignInPrefilledState,
|
||||
@ -92,7 +94,7 @@ describe('useAuth', () => {
|
||||
client,
|
||||
state: {
|
||||
icons,
|
||||
authProviders,
|
||||
workspaceAuthProviders,
|
||||
billing,
|
||||
isDeveloperDefaultSignInPrefilled,
|
||||
supportChat,
|
||||
@ -118,7 +120,7 @@ describe('useAuth', () => {
|
||||
const { state } = result.current;
|
||||
|
||||
expect(state.icons).toEqual({});
|
||||
expect(state.authProviders).toEqual({
|
||||
expect(state.workspaceAuthProviders).toEqual({
|
||||
google: true,
|
||||
microsoft: false,
|
||||
magicLink: false,
|
||||
|
||||
@ -13,7 +13,6 @@ import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { isCurrentUserLoadedState } from '@/auth/states/isCurrentUserLoadingState';
|
||||
import { isVerifyPendingState } from '@/auth/states/isVerifyPendingState';
|
||||
import { workspacesState } from '@/auth/states/workspaces';
|
||||
import { authProvidersState } from '@/client-config/states/authProvidersState';
|
||||
import { billingState } from '@/client-config/states/billingState';
|
||||
import { captchaProviderState } from '@/client-config/states/captchaProviderState';
|
||||
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
|
||||
@ -48,6 +47,7 @@ import { useLastAuthenticatedWorkspaceDomain } from '@/domain-manager/hooks/useL
|
||||
import { useReadWorkspaceSubdomainFromCurrentLocation } from '@/domain-manager/hooks/useReadWorkspaceSubdomainFromCurrentLocation';
|
||||
import { domainConfigurationState } from '@/domain-manager/states/domainConfigurationState';
|
||||
import { isAppWaitingForFreshObjectMetadataState } from '@/object-metadata/states/isAppWaitingForFreshObjectMetadataState';
|
||||
import { workspaceAuthProvidersState } from '@/workspace/states/workspaceAuthProvidersState';
|
||||
|
||||
export const useAuth = () => {
|
||||
const setTokenPair = useSetRecoilState(tokenPairState);
|
||||
@ -90,7 +90,7 @@ export const useAuth = () => {
|
||||
const emptySnapshot = snapshot_UNSTABLE();
|
||||
const iconsValue = snapshot.getLoadable(iconsState).getValue();
|
||||
const authProvidersValue = snapshot
|
||||
.getLoadable(authProvidersState)
|
||||
.getLoadable(workspaceAuthProvidersState)
|
||||
.getValue();
|
||||
const billing = snapshot.getLoadable(billingState).getValue();
|
||||
const isDeveloperDefaultSignInPrefilled = snapshot
|
||||
@ -115,7 +115,7 @@ export const useAuth = () => {
|
||||
.getValue();
|
||||
const initialSnapshot = emptySnapshot.map(({ set }) => {
|
||||
set(iconsState, iconsValue);
|
||||
set(authProvidersState, authProvidersValue);
|
||||
set(workspaceAuthProvidersState, authProvidersValue);
|
||||
set(billingState, billing);
|
||||
set(
|
||||
isDeveloperDefaultSignInPrefilledState,
|
||||
|
||||
Reference in New Issue
Block a user