diff --git a/frontend/src/components/login/InitialLoginStep.tsx b/frontend/src/components/login/InitialLoginStep.tsx index 79b10bbdeb..77e83434e5 100644 --- a/frontend/src/components/login/InitialLoginStep.tsx +++ b/frontend/src/components/login/InitialLoginStep.tsx @@ -1,19 +1,65 @@ +import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import Link from 'next/link'; import { useRouter } from 'next/router'; +import attemptLogin from '@app/components/utilities/attemptLogin'; + +import Error from '../basic/Error'; // import { faGoogle } from '@fortawesome/free-brands-svg-icons'; // import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { Button } from '../v2'; +import { Button, Input } from '../v2'; export default function InitialLoginStep({ - setIsLoginWithEmail, + setStep, + email, + setEmail, + password, + setPassword, }: { - setIsLoginWithEmail: (value: boolean) => void; + setStep: (step: number) => void; + email: string; + setEmail: (email: string) => void; + password: string; + setPassword: (password: string) => void; }) { const router = useRouter(); const { t } = useTranslation(); + const [isLoading, setIsLoading] = useState(false); + const [loginError, setLoginError] = useState(false); + + const handleLogin = async () => { + try { + if (!email || !password) { + return; + } + + setIsLoading(true); + const isLoginSuccessful = await attemptLogin({ + email, + password, + }); + if (isLoginSuccessful && isLoginSuccessful.success) { + // case: login was successful + + if (isLoginSuccessful.mfaEnabled) { + // case: login requires MFA step + setStep(2); + setIsLoading(false); + return; + } + + // case: login does not require MFA step + router.push(`/dashboard/${localStorage.getItem('projectData.id')}`); + } + + } catch (err) { + setLoginError(true); + } + + setIsLoading(false); + } return

Login to Infisical

@@ -30,18 +76,49 @@ export default function InitialLoginStep({ {t('login.continue-with-google')}
*/} -
+
+
+ setEmail(e.target.value)} + type="email" + placeholder="Enter your email..." + isRequired + autoComplete="username" + className="h-12" + /> +
+
+
+
+ setPassword(e.target.value)} + type="password" + placeholder="Enter your password..." + isRequired + autoComplete="current-password" + id="current-password" + className="h-12 select:-webkit-autofill:focus" + /> +
+
+ {!isLoading && loginError && } +
+ className='h-12' + colorSchema="primary" + variant="solid" + isLoading={isLoading} + > Login +
+
+
+ or +
-
+
Don't have an acount yet? {t('login.create-account')} diff --git a/frontend/src/components/login/MFAStep.tsx b/frontend/src/components/login/MFAStep.tsx index 38ae9d831d..a619cf07b9 100644 --- a/frontend/src/components/login/MFAStep.tsx +++ b/frontend/src/components/login/MFAStep.tsx @@ -16,10 +16,10 @@ const props = { fontFamily: 'monospace', margin: '4px', MozAppearance: 'textfield', - width: '55px', + width: '48px', borderRadius: '5px', fontSize: '24px', - height: '55px', + height: '48px', paddingLeft: '7', backgroundColor: '#0d1117', color: 'white', @@ -115,7 +115,7 @@ export default function MFAStep({ }; return ( -
+

{t('mfa.step2-message')}

{email}

diff --git a/frontend/src/components/signup/CodeInputStep.tsx b/frontend/src/components/signup/CodeInputStep.tsx index a13a34f117..c73199bf3b 100644 --- a/frontend/src/components/signup/CodeInputStep.tsx +++ b/frontend/src/components/signup/CodeInputStep.tsx @@ -85,7 +85,7 @@ export default function CodeInputStep({ }; return ( -
+

{t('signup.step2-message')}

{email}

diff --git a/frontend/src/components/signup/DonwloadBackupPDFStep.tsx b/frontend/src/components/signup/DonwloadBackupPDFStep.tsx index dcfd7210f3..3d20ea1d47 100644 --- a/frontend/src/components/signup/DonwloadBackupPDFStep.tsx +++ b/frontend/src/components/signup/DonwloadBackupPDFStep.tsx @@ -34,7 +34,7 @@ export default function DonwloadBackupPDFStep({

{t('signup.step4-message')}

-
+
{t('signup.step4-description1')} {t('signup.step4-description3')}
diff --git a/frontend/src/components/signup/InitialSignupStep.tsx b/frontend/src/components/signup/InitialSignupStep.tsx index 0de7a91c0c..43a3ee7fe4 100644 --- a/frontend/src/components/signup/InitialSignupStep.tsx +++ b/frontend/src/components/signup/InitialSignupStep.tsx @@ -39,7 +39,7 @@ export default function InitialSignupStep({ isFullWidth className="h-14 w-full mx-0" > - {t('signup.continue-with-email')} + Sign Up with email
diff --git a/frontend/src/components/signup/UserInfoStep.tsx b/frontend/src/components/signup/UserInfoStep.tsx index 314e1e13a5..09aefa8844 100644 --- a/frontend/src/components/signup/UserInfoStep.tsx +++ b/frontend/src/components/signup/UserInfoStep.tsx @@ -205,11 +205,11 @@ export default function UserInfoStep({ }; return ( -
+

{t('signup.step3-message')}

-
+

Your Name

- ); - } - - if (!isLoginWithEmail && loginStep === 1) { - return ; + if (loginStep === 1) { + return ; } if (step === 2) { diff --git a/frontend/src/pages/saml-sso.tsx b/frontend/src/pages/saml-sso.tsx index 31408778e7..0c955f5964 100644 --- a/frontend/src/pages/saml-sso.tsx +++ b/frontend/src/pages/saml-sso.tsx @@ -46,16 +46,16 @@ export default function Login() { Infisical logo
-
+

What’s your email?

-
+
setPassword(e.target.value)} - type="password" + type="email" placeholder="Enter your email..." isRequired autoComplete="email" @@ -64,7 +64,7 @@ export default function Login() { />
-
+