From bd50ed4c5eeebe1507c0b989dda45ec4ac0389ac Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 17 Jan 2023 15:02:09 +0000 Subject: [PATCH 1/6] fix: login image shadow --- frontend/src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index f68e61224..98d0ac11f 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -125,7 +125,7 @@ const Home: NextPage = () => { flexShrink: 0, }} > - + ); From c77c9c0b48cb97cfa7c72b1c0f273674f7ba4869 Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 17 Jan 2023 17:03:04 +0000 Subject: [PATCH 2/6] fix: no account yet position --- frontend/src/pages/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 98d0ac11f..8ccdc0336 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -43,7 +43,7 @@ const Home: NextPage = () => { const renderFooter = () => { if (!NEXT_PUBLIC_LOGIN_SSO_ONLY) { return currentTab === 'login' ? ( - + No account yet?{' '} { ) : ( - + Already have an account?{' '} { ml: '$72', mr: '$72', mt: '9.7%', + mb: '$24', height: '100%', justifyContent: 'space-between', }} From 26166d1999995e167bf37db16cd39aac4e8282c5 Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 17 Jan 2023 17:03:57 +0000 Subject: [PATCH 3/6] fix: password eye icon color --- frontend/src/components/Primitives/Input.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/Primitives/Input.tsx b/frontend/src/components/Primitives/Input.tsx index 79feeaed9..251ac2931 100644 --- a/frontend/src/components/Primitives/Input.tsx +++ b/frontend/src/components/Primitives/Input.tsx @@ -277,6 +277,7 @@ const Input: React.FC = ({ css={{ width: '$24', height: '$24', + color: '$primary300', }} /> )} From ac6ebbc858990923bc80fbb0f288df80ade1621d Mon Sep 17 00:00:00 2001 From: JoaoSaIvador Date: Wed, 18 Jan 2023 11:53:36 +0000 Subject: [PATCH 4/6] fix: change login error message with status code --- .../src/components/auth/LoginForm/index.tsx | 3 +- frontend/src/pages/api/auth/[...nextauth].tsx | 39 ++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/auth/LoginForm/index.tsx b/frontend/src/components/auth/LoginForm/index.tsx index b7cde9385..9c2a40f44 100644 --- a/frontend/src/components/auth/LoginForm/index.tsx +++ b/frontend/src/components/auth/LoginForm/index.tsx @@ -11,7 +11,6 @@ import { DotsLoading } from '@/components/loadings/DotsLoading'; import Flex from '@/components/Primitives/Flex'; import Input from '@/components/Primitives/Input'; import Text from '@/components/Primitives/Text'; -import { getAuthError } from '@/errors/auth-messages'; import useUser from '@/hooks/useUser'; import SchemaLoginForm from '@/schema/schemaLoginForm'; import { toastState } from '@/store/toast/atom/toast.atom'; @@ -77,7 +76,7 @@ const LoginForm: React.FC = ({ setShowTroubleLogin }) => { setToastState({ open: true, type: ToastStateEnum.ERROR, - content: getAuthError(result.status), + content: result.error, }); } diff --git a/frontend/src/pages/api/auth/[...nextauth].tsx b/frontend/src/pages/api/auth/[...nextauth].tsx index 46ad17a20..17ceed95b 100644 --- a/frontend/src/pages/api/auth/[...nextauth].tsx +++ b/frontend/src/pages/api/auth/[...nextauth].tsx @@ -16,6 +16,7 @@ import { UNDEFINED, } from '@/utils/constants'; import { DASHBOARD_ROUTE, ERROR_500_PAGE, START_PAGE_ROUTE } from '@/utils/routes'; +import { getAuthError } from '@/errors/auth-messages'; async function getNewAccessToken(prevToken: JWT): Promise { try { @@ -52,21 +53,31 @@ export default NextAuth({ email: credentials?.email, password: credentials?.password, }; - const data = await login(loginUser); - const { firstName, lastName, isSAdmin, accessToken, refreshToken, _id, email } = data || {}; - if (!_id || !accessToken || !refreshToken) return null; - const token = { - firstName, - lastName, - isSAdmin, - accessToken, - refreshToken, - id: _id, - email, - strategy: 'local', - }; - return token; + try { + const data = await login(loginUser); + + const { firstName, lastName, isSAdmin, accessToken, refreshToken, _id, email } = + data || {}; + if (!_id || !accessToken || !refreshToken) return null; + + const token = { + firstName, + lastName, + isSAdmin, + accessToken, + refreshToken, + id: _id, + email, + strategy: 'local', + }; + return token; + } catch (error: any) { + const code = error.response.status; + throw Error(getAuthError(code)); + } + + // getAuthError(result.status), }, }), ], From 4b2b9aff1eb5279a976dd11582c36c44185baac2 Mon Sep 17 00:00:00 2001 From: Guido Date: Wed, 18 Jan 2023 14:36:15 +0000 Subject: [PATCH 5/6] fix: signup display error --- frontend/src/components/Primitives/Input.tsx | 2 +- .../src/components/auth/SignUp/SignUpForm.tsx | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/Primitives/Input.tsx b/frontend/src/components/Primitives/Input.tsx index 251ac2931..c85cb891e 100644 --- a/frontend/src/components/Primitives/Input.tsx +++ b/frontend/src/components/Primitives/Input.tsx @@ -235,7 +235,7 @@ const Input: React.FC = ({ const isValueEmpty = isEmpty(value); const autoState = useMemo(() => { - if (message) return 'error'; + if (Object.keys(errors).length > 0 || message) return 'error'; if (isValueEmpty) return 'default'; if (!message && !isValueEmpty) return 'valid'; return undefined; diff --git a/frontend/src/components/auth/SignUp/SignUpForm.tsx b/frontend/src/components/auth/SignUp/SignUpForm.tsx index 95abe338b..012f99c0e 100644 --- a/frontend/src/components/auth/SignUp/SignUpForm.tsx +++ b/frontend/src/components/auth/SignUp/SignUpForm.tsx @@ -16,7 +16,6 @@ import { toastState } from '@/store/toast/atom/toast.atom'; import { EmailUser } from '@/types/user/user'; import { NEXT_PUBLIC_ENABLE_AZURE } from '@/utils/constants'; import { ToastStateEnum } from '@/utils/enums/toast-types'; -import isEmpty from '@/utils/isEmpty'; import { SignUpEnum } from '@/utils/signUp.enum'; const StyledForm = styled('form', Flex, { width: '100%' }); @@ -29,8 +28,15 @@ interface SignUpFormProps { const SignUpForm: React.FC = ({ setShowSignUp, setEmailName, emailName }) => { const setToastState = useSetRecoilState(toastState); - const [valueHelperText, setValueHelperText] = useState(''); const [valueState, setValueState] = useState(false); + const methods = useForm({ + mode: 'onBlur', + reValidateMode: 'onBlur', + defaultValues: { + email: emailName.email, + }, + resolver: joiResolver(SchemaEmail), + }); useQuery( ['checkUserExists', emailName], () => @@ -51,7 +57,7 @@ const SignUpForm: React.FC = ({ setShowSignUp, setEmailName, em return; } - setValueHelperText(' This email already exists'); + methods.setError('email', { type: 'custom', message: 'This email already exists' }); setValueState(true); }, @@ -72,14 +78,6 @@ const SignUpForm: React.FC = ({ setShowSignUp, setEmailName, em }, }, ); - const methods = useForm({ - mode: 'onSubmit', - reValidateMode: 'onSubmit', - defaultValues: { - email: emailName.email, - }, - resolver: joiResolver(SchemaEmail), - }); const handleCheckUserExists = async (email: string) => { setEmailName({ goback: false, email }); @@ -108,9 +106,9 @@ const SignUpForm: React.FC = ({ setShowSignUp, setEmailName, em Enter your email address to proceed further + Date: Wed, 18 Jan 2023 16:57:46 +0000 Subject: [PATCH 6/6] fix: wrong credentials validation --- frontend/src/components/Primitives/Input.tsx | 5 ++--- frontend/src/components/auth/LoginForm/index.tsx | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Primitives/Input.tsx b/frontend/src/components/Primitives/Input.tsx index c85cb891e..9fd0bcdd4 100644 --- a/frontend/src/components/Primitives/Input.tsx +++ b/frontend/src/components/Primitives/Input.tsx @@ -235,11 +235,10 @@ const Input: React.FC = ({ const isValueEmpty = isEmpty(value); const autoState = useMemo(() => { - if (Object.keys(errors).length > 0 || message) return 'error'; - if (isValueEmpty) return 'default'; + if (errors[id]) return 'error'; if (!message && !isValueEmpty) return 'valid'; return undefined; - }, [message, isValueEmpty]); + }, [errors, message, isValueEmpty]); const currentState = useMemo(() => { if (disabled && !touchedFields[id] && !forceState) return 'default'; diff --git a/frontend/src/components/auth/LoginForm/index.tsx b/frontend/src/components/auth/LoginForm/index.tsx index 9c2a40f44..7487399aa 100644 --- a/frontend/src/components/auth/LoginForm/index.tsx +++ b/frontend/src/components/auth/LoginForm/index.tsx @@ -73,6 +73,8 @@ const LoginForm: React.FC = ({ setShowTroubleLogin }) => { setLoginErrorCode(result.status); if (result.error) { + methods.setError('email', { type: 'custom', message: '' }); + methods.setError('password', { type: 'custom', message: '' }); setToastState({ open: true, type: ToastStateEnum.ERROR,