Feat/navigate to signup if email does not exist (#540)
* Add userExists route * Fix demo mode for login * Improve sign in/up flow * Remove redundant password length constraint * Fix test
This commit is contained in:
@ -12,6 +12,7 @@ import { Title } from '@/auth/components/ui/Title';
|
||||
import { authFlowUserEmailState } from '@/auth/states/authFlowUserEmailState';
|
||||
import { isMockModeState } from '@/auth/states/isMockModeState';
|
||||
import { authProvidersState } from '@/client-config/states/authProvidersState';
|
||||
import { isDemoModeState } from '@/client-config/states/isDemoModeState';
|
||||
import { useScopedHotkeys } from '@/hotkeys/hooks/useScopedHotkeys';
|
||||
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
|
||||
import { MainButton } from '@/ui/components/buttons/MainButton';
|
||||
@ -35,7 +36,7 @@ export function Index() {
|
||||
const theme = useTheme();
|
||||
const [, setMockMode] = useRecoilState(isMockModeState);
|
||||
const [authProviders] = useRecoilState(authProvidersState);
|
||||
const [demoMode] = useRecoilState(authProvidersState);
|
||||
const [demoMode] = useRecoilState(isDemoModeState);
|
||||
|
||||
const [authFlowUserEmail, setAuthFlowUserEmail] = useRecoilState(
|
||||
authFlowUserEmailState,
|
||||
|
||||
@ -16,6 +16,7 @@ import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysSc
|
||||
import { MainButton } from '@/ui/components/buttons/MainButton';
|
||||
import { TextInput } from '@/ui/components/inputs/TextInput';
|
||||
import { SubSectionTitle } from '@/ui/components/section-titles/SubSectionTitle';
|
||||
import { useCheckUserExistsQuery } from '~/generated/graphql';
|
||||
|
||||
const StyledContentContainer = styled.div`
|
||||
width: 100%;
|
||||
@ -84,11 +85,20 @@ export function PasswordLogin() {
|
||||
[handleLogin],
|
||||
);
|
||||
|
||||
const { loading, data } = useCheckUserExistsQuery({
|
||||
variables: {
|
||||
email: authFlowUserEmail,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Logo />
|
||||
<Title>Welcome to Twenty</Title>
|
||||
<SubTitle>Enter your credentials to sign in</SubTitle>
|
||||
<SubTitle>
|
||||
Enter your credentials to sign{' '}
|
||||
{data?.checkUserExists.exists ? 'in' : 'up'}
|
||||
</SubTitle>
|
||||
<StyledAnimatedContent>
|
||||
<StyledContentContainer>
|
||||
<StyledSectionContainer>
|
||||
@ -115,7 +125,7 @@ export function PasswordLogin() {
|
||||
<MainButton
|
||||
title="Continue"
|
||||
onClick={handleLogin}
|
||||
disabled={!authFlowUserEmail || !internalPassword}
|
||||
disabled={!authFlowUserEmail || !internalPassword || loading}
|
||||
fullWidth
|
||||
/>
|
||||
</StyledButtonContainer>
|
||||
|
||||
Reference in New Issue
Block a user