diff --git a/client/src/containers/Authentication/Login.js b/client/src/containers/Authentication/Login.js
index 6dabb1606..3fe43f534 100644
--- a/client/src/containers/Authentication/Login.js
+++ b/client/src/containers/Authentication/Login.js
@@ -25,24 +25,26 @@ import { compose } from 'utils';
const ERRORS_TYPES = {
INVALID_DETAILS: 'INVALID_DETAILS',
USER_INACTIVE: 'USER_INACTIVE',
+ LOGIN_TO_MANY_ATTEMPTS: 'LOGIN_TO_MANY_ATTEMPTS',
};
-function Login({
- requestLogin,
-}) {
+function Login({ requestLogin }) {
const { formatMessage } = useIntl();
const history = useHistory();
const [shown, setShown] = useState(false);
- const passwordRevealer = () => { setShown(!shown); };
-
+ const passwordRevealer = () => {
+ setShown(!shown);
+ };
// Validation schema.
const loginValidationSchema = Yup.object().shape({
crediential: Yup.string()
.required()
- .email().label(formatMessage({id:'email'})),
+ .email()
+ .label(formatMessage({ id: 'email' })),
password: Yup.string()
.required()
- .min(4).label(formatMessage({id:'password'}))
+ .min(4)
+ .label(formatMessage({ id: 'password' })),
});
// Formik validation schema and submit handler.
@@ -62,58 +64,97 @@ function Login({
requestLogin({
crediential: values.crediential,
password: values.password,
- }).then(() => {
- setSubmitting(false);
- }).catch((errors) => {
- const toastBuilders = [];
- if (errors.find((e) => e.type === ERRORS_TYPES.INVALID_DETAILS)) {
- toastBuilders.push({
- message: formatMessage({ id: 'email_and_password_entered_did_not_match' }),
- intent: Intent.DANGER,
+ })
+ .then(() => {
+ setSubmitting(false);
+ })
+ .catch((errors) => {
+ const toastBuilders = [];
+ if (errors.find((e) => e.type === ERRORS_TYPES.INVALID_DETAILS)) {
+ toastBuilders.push({
+ message: formatMessage({
+ id: 'email_and_password_entered_did_not_match',
+ }),
+ intent: Intent.DANGER,
+ });
+ }
+ if (errors.find((e) => e.type === ERRORS_TYPES.USER_INACTIVE)) {
+ toastBuilders.push({
+ message: formatMessage({
+ id: 'the_user_has_been_suspended_from_admin',
+ }),
+ intent: Intent.DANGER,
+ });
+ }
+ if (
+ errors.find((e) => e.type === ERRORS_TYPES.LOGIN_TO_MANY_ATTEMPTS)
+ ) {
+ toastBuilders.push({
+ message: formatMessage({
+ id: 'your_account_has_been_locked',
+ }),
+ intent: Intent.DANGER,
+ });
+ }
+ toastBuilders.forEach((builder) => {
+ Toaster.show(builder);
});
- }
- if (errors.find((e) => e.type === ERRORS_TYPES.USER_INACTIVE)) {
- toastBuilders.push({
- message: formatMessage({ id: 'the_user_has_been_suspended_from_admin' }),
- intent: Intent.DANGER,
- });
- }
- toastBuilders.forEach(builder => {
- Toaster.show(builder);
+ setSubmitting(false);
});
- setSubmitting(false);
- });
},
});
- const passwordRevealerTmp = useMemo(() => (
- passwordRevealer()}>
-
- <> >
-
-
- <> >
-
- ), [shown, passwordRevealer]);
+ const passwordRevealerTmp = useMemo(
+ () => (
+ passwordRevealer()}>
+
+ <>
+ {' '}
+
+
+
+ >
+
+
+ <>
+ {' '}
+
+
+
+ >
+
+
+ ),
+ [shown, passwordRevealer],
+ );
return (
-