From e0f82d94b2b2f1e1e0023a89a5a26a0c2ff2b1b2 Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 4 Jan 2024 14:55:06 +0100 Subject: [PATCH 01/11] =?UTF-8?q?Ajout=20de=20la=20v=C3=A9rification=20de?= =?UTF-8?q?=20tentative=20de=20MDP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 + src/actions/user.actions.js | 29 +++++++- src/components/anonymous/Login.js | 32 ++++++++ src/components/anonymous/ModalVerifyCode.js | 82 +++++++++++++++++++++ src/reducers/createAccountReducer.js | 20 +++++ src/services/user.service.js | 26 ++++++- 6 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 src/components/anonymous/ModalVerifyCode.js diff --git a/package.json b/package.json index b93da8f..e7f1b50 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,9 @@ "react-datepicker": "^4.16.0", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", + "react-flash-message": "^1.0.8", "react-loader-spinner": "^5.3.4", + "react-pluralize": "^1.6.3", "react-redux": "^8.1.2", "react-router-dom": "^6.14.2", "react-scripts": "5.0.1", diff --git a/src/actions/user.actions.js b/src/actions/user.actions.js index 7578193..6a1a8b8 100644 --- a/src/actions/user.actions.js +++ b/src/actions/user.actions.js @@ -9,7 +9,8 @@ export const userActions = { inviteAccountsPrefet, forgottenPassword, updateInfosCandidat, - confirmUserEmail + confirmUserEmail, + verifyCode, }; function login(username, password) { @@ -207,6 +208,7 @@ function updateInfosCandidat({ id, infos }) { return { type: 'UPDATE_USER_EMAIL_FAILURE', error }; } } + function confirmUserEmail(token) { return dispatch => { dispatch(request()); @@ -229,3 +231,28 @@ function confirmUserEmail(token) { return { type: 'CONFIRMATION_UPDATE_USER_EMAIL_FAILURE', error }; } } + +function verifyCode(code, email) { + return dispatch => { + dispatch(request()); + userService.verifyCode(code, email) + .then( + result => { + dispatch(success(result)); + }, + error => { + dispatch(failure(error)); + } + ); + }; + + function request() { + return { type: 'VERIFY_CODE_CONNEXION_REQUEST' }; + } + function success(result) { + return { type: 'VERIFY_CODE_CONNEXION_SUCCESS', result }; + } + function failure(error) { + return { type: 'VERIFY_CODE_CONNEXION_FAILURE', error }; + } +} diff --git a/src/components/anonymous/Login.js b/src/components/anonymous/Login.js index e77fca3..1729a92 100644 --- a/src/components/anonymous/Login.js +++ b/src/components/anonymous/Login.js @@ -1,11 +1,14 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; +import FlashMessage from 'react-flash-message'; +import Pluralize from 'react-pluralize'; import { alerteEtSpinnerActions, userActions } from '../../actions'; import Header from '../common/Header'; import ModalResetPassword from './ModalResetPassword'; import Spinner from '../common/Spinner'; import Alerte from '../common/Alerte'; +import ModalVerifyCode from './ModalVerifyCode'; function Login() { @@ -16,6 +19,8 @@ function Login() { const [submitted, setSubmitted] = useState(false); const [showModalResetPassword, setShowModalResetPassword] = useState(false); + const [showModalVerifyCode, setShowModalVerifyCode] = useState(false); + const [countAttempt, setCountAttempt] = useState(3); const { username, password } = inputs; const loggingIn = useSelector(state => state.authentication.loggingIn); const error = useSelector(state => state.authentication.error); @@ -23,6 +28,7 @@ function Login() { const errorEmail = useSelector(state => state.motDePasseOublie.error); const validEmail = useSelector(state => state.motDePasseOublie.success); const loading = useSelector(state => state.motDePasseOublie?.loading); + const messageCodeVerified = useSelector(state => state.createAccount.messageCodeVerified); const dispatch = useDispatch(); const location = useLocation(); @@ -46,6 +52,10 @@ function Login() { useEffect(() => { if (error?.resetPasswordCnil) { setShowModalResetPassword(true); + } else if (error?.attemptFail) { + setCountAttempt(3 - error?.attemptFail); + } else if (error?.openPopinVerifyCode) { + setShowModalVerifyCode(true); } }, [error]); @@ -70,10 +80,20 @@ function Login() {
+ {messageCodeVerified && + +

+ {messageCodeVerified} +

+
+ } {showModalResetPassword && } + {showModalVerifyCode && + + }
@@ -106,6 +126,18 @@ function Login() {
Mot de passe requis
}
+ {error?.attemptFail < 3 && +
Erreur de mot de passe, il ne vous reste plus que  + .
+ } + {error?.attemptFail === 3 && +
Votre compte est bloqué pour les 10 prochaines minutes.
+ } {loggingIn && Connexion en cours...}

diff --git a/src/components/anonymous/ModalVerifyCode.js b/src/components/anonymous/ModalVerifyCode.js new file mode 100644 index 0000000..576fcd8 --- /dev/null +++ b/src/components/anonymous/ModalVerifyCode.js @@ -0,0 +1,82 @@ +import React, { useEffect, useState } from 'react'; +import PropTypes from 'prop-types'; +import { userActions } from '../../actions'; +import { useDispatch, useSelector } from 'react-redux'; + +const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => { + const dispatch = useDispatch(); + const [code, setCode] = useState(''); + const codeVerified = useSelector(state => state.createAccount?.codeVerified); + const errorVerifyingCode = useSelector(state => state.createAccount?.errorVerifyingCode); + + function handleSendCode() { + dispatch(userActions.verifyCode(code, email)); + } + + function handleChange(e) { + const { value } = e.target; + setCode(value); + } + + useEffect(() => { + if (codeVerified) { + window.scrollTo({ top: 0, behavior: 'smooth' }); + setShowModalVerifyCode(false); + } + }, [codeVerified]); + + return ( +

+
+
+
+
+
+
+
+

+ + Vérification du compte conseiller +

+

+ Conformément aux règles de sécurité des mots de passe, + un code de vérification vous a été envoyé sur votre + adresse email de connexion. + Merci de le renseigner ici. +

+ +
+ + + {errorVerifyingCode && +
{errorVerifyingCode}
+ } +
+
+
+ +
+
+
+
+
+
+ ); +}; + +ModalVerifyCode.propTypes = { + setShowModalVerifyCode: PropTypes.func, + email: PropTypes.string +}; + +export default ModalVerifyCode; diff --git a/src/reducers/createAccountReducer.js b/src/reducers/createAccountReducer.js index 7145e91..ca8dbbb 100644 --- a/src/reducers/createAccountReducer.js +++ b/src/reducers/createAccountReducer.js @@ -30,6 +30,26 @@ export default function authentication(state = {}, action) { passwordChoosen: false, error: action.error }; + case 'VERIFY_CODE_CONNEXION_REQUEST': + return { + ...state, + verifyingCode: true, + codeVerified: false, + errorVerifyingCode: '', + }; + case 'VERIFY_CODE_CONNEXION_SUCCESS': + return { + ...state, + verifyingCode: false, + codeVerified: true, + messageCodeVerified: action.result.messageVerificationCode, + }; + case 'VERIFY_CODE_CONNEXION_FAILURE': + return { + ...state, + verifyingCode: false, + errorVerifyingCode: action.error.error ? action.error.error : action.error, + }; default: return state; } diff --git a/src/services/user.service.js b/src/services/user.service.js index 45fc9bc..e3fed51 100644 --- a/src/services/user.service.js +++ b/src/services/user.service.js @@ -7,7 +7,8 @@ export const userService = { choosePassword, updateInfosCandidat, confirmUserEmail, - sendForgottenPasswordEmail + sendForgottenPasswordEmail, + verifyCode, }; function login(username, password) { @@ -105,6 +106,23 @@ function sendForgottenPasswordEmail(username) { return fetch(uri, requestOptions).then(handleResponse); } +function verifyCode(code, email) { + const apiUrlRoot = process.env.REACT_APP_API; + + const requestOptions = { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + 'code': code, 'email': email + }) + }; + + let uri = `${apiUrlRoot}/users/verify-code`; + return fetch(uri, requestOptions).then(handleResponse); +} + function handleResponse(response) { return response.text().then(text => { const data = text && JSON.parse(text); @@ -116,6 +134,12 @@ function handleResponse(response) { if (data?.data?.resetPasswordCnil && data.message === 'RESET_PASSWORD_CNIL') { return Promise.reject({ resetPasswordCnil: true }); } + if (data?.data?.attemptFail && (data.message === 'ERROR_ATTEMPT_LOGIN' || data.message === 'ERROR_ATTEMPT_LOGIN_BLOCKED')) { + return Promise.reject({ attemptFail: data?.data?.attemptFail }); + } + if (data?.data?.openPopinVerifyCode && data.message === 'PROCESS_LOGIN_UNBLOCKED') { + return Promise.reject({ openPopinVerifyCode: true }); + } const error = (data && data.message) || response.statusText; return Promise.reject(error); } From 8d669acb418feb17d9fa783e27e00058d452bfff Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 4 Jan 2024 16:11:56 +0100 Subject: [PATCH 02/11] correction suite aux retours de la PR conseiller --- src/components/anonymous/Login.js | 2 +- src/components/anonymous/ModalVerifyCode.js | 8 ++++---- src/reducers/authenticationReducer.js | 19 +++++++++++++++++++ src/reducers/createAccountReducer.js | 20 -------------------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/components/anonymous/Login.js b/src/components/anonymous/Login.js index 1729a92..c793c71 100644 --- a/src/components/anonymous/Login.js +++ b/src/components/anonymous/Login.js @@ -28,7 +28,7 @@ function Login() { const errorEmail = useSelector(state => state.motDePasseOublie.error); const validEmail = useSelector(state => state.motDePasseOublie.success); const loading = useSelector(state => state.motDePasseOublie?.loading); - const messageCodeVerified = useSelector(state => state.createAccount.messageCodeVerified); + const messageCodeVerified = useSelector(state => state.authentication.messageCodeVerified); const dispatch = useDispatch(); const location = useLocation(); diff --git a/src/components/anonymous/ModalVerifyCode.js b/src/components/anonymous/ModalVerifyCode.js index 576fcd8..001a526 100644 --- a/src/components/anonymous/ModalVerifyCode.js +++ b/src/components/anonymous/ModalVerifyCode.js @@ -6,8 +6,8 @@ import { useDispatch, useSelector } from 'react-redux'; const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => { const dispatch = useDispatch(); const [code, setCode] = useState(''); - const codeVerified = useSelector(state => state.createAccount?.codeVerified); - const errorVerifyingCode = useSelector(state => state.createAccount?.errorVerifyingCode); + const messageCodeVerified = useSelector(state => state.authentication?.messageCodeVerified); + const errorVerifyingCode = useSelector(state => state.authentication?.errorVerifyingCode); function handleSendCode() { dispatch(userActions.verifyCode(code, email)); @@ -19,11 +19,11 @@ const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => { } useEffect(() => { - if (codeVerified) { + if (messageCodeVerified) { window.scrollTo({ top: 0, behavior: 'smooth' }); setShowModalVerifyCode(false); } - }, [codeVerified]); + }, [messageCodeVerified]); return ( diff --git a/src/reducers/authenticationReducer.js b/src/reducers/authenticationReducer.js index 07d08b5..701a208 100644 --- a/src/reducers/authenticationReducer.js +++ b/src/reducers/authenticationReducer.js @@ -19,6 +19,25 @@ export default function authentication(state = initialState, action) { }; case 'LOGOUT': return {}; + case 'VERIFY_CODE_CONNEXION_REQUEST': + return { + ...state, + verifyingCode: true, + messageCodeVerified: '', + errorVerifyingCode: '', + }; + case 'VERIFY_CODE_CONNEXION_SUCCESS': + return { + ...state, + verifyingCode: false, + messageCodeVerified: action.result.messageVerificationCode, + }; + case 'VERIFY_CODE_CONNEXION_FAILURE': + return { + ...state, + verifyingCode: false, + errorVerifyingCode: action.error, + }; default: return state; } diff --git a/src/reducers/createAccountReducer.js b/src/reducers/createAccountReducer.js index ca8dbbb..7145e91 100644 --- a/src/reducers/createAccountReducer.js +++ b/src/reducers/createAccountReducer.js @@ -30,26 +30,6 @@ export default function authentication(state = {}, action) { passwordChoosen: false, error: action.error }; - case 'VERIFY_CODE_CONNEXION_REQUEST': - return { - ...state, - verifyingCode: true, - codeVerified: false, - errorVerifyingCode: '', - }; - case 'VERIFY_CODE_CONNEXION_SUCCESS': - return { - ...state, - verifyingCode: false, - codeVerified: true, - messageCodeVerified: action.result.messageVerificationCode, - }; - case 'VERIFY_CODE_CONNEXION_FAILURE': - return { - ...state, - verifyingCode: false, - errorVerifyingCode: action.error.error ? action.error.error : action.error, - }; default: return state; } From 9a7c59fcfc2c22f983f1cc7d9643f46cb0299e6d Mon Sep 17 00:00:00 2001 From: morgan Date: Fri, 5 Jan 2024 11:14:22 +0100 Subject: [PATCH 03/11] retours PR conseiller --- src/components/anonymous/ModalVerifyCode.js | 5 ++--- src/services/user.service.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/anonymous/ModalVerifyCode.js b/src/components/anonymous/ModalVerifyCode.js index 001a526..aebe811 100644 --- a/src/components/anonymous/ModalVerifyCode.js +++ b/src/components/anonymous/ModalVerifyCode.js @@ -14,8 +14,7 @@ const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => { } function handleChange(e) { - const { value } = e.target; - setCode(value); + setCode(e.target.value); } useEffect(() => { @@ -41,7 +40,7 @@ const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => {

Conformément aux règles de sécurité des mots de passe, un code de vérification vous a été envoyé sur votre - adresse email de connexion. + adresse email personnelle. Merci de le renseigner ici.

diff --git a/src/services/user.service.js b/src/services/user.service.js index e3fed51..af7250c 100644 --- a/src/services/user.service.js +++ b/src/services/user.service.js @@ -138,7 +138,7 @@ function handleResponse(response) { return Promise.reject({ attemptFail: data?.data?.attemptFail }); } if (data?.data?.openPopinVerifyCode && data.message === 'PROCESS_LOGIN_UNBLOCKED') { - return Promise.reject({ openPopinVerifyCode: true }); + return Promise.reject({ openPopinVerifyCode: data?.data?.openPopinVerifyCode }); } const error = (data && data.message) || response.statusText; return Promise.reject(error); From f9987eaee45b60c310bfdfcc94f58662ab0a014f Mon Sep 17 00:00:00 2001 From: morgan Date: Tue, 9 Jan 2024 16:25:00 +0100 Subject: [PATCH 04/11] simplification du code --- src/services/user.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/user.service.js b/src/services/user.service.js index af7250c..f8b99f2 100644 --- a/src/services/user.service.js +++ b/src/services/user.service.js @@ -115,7 +115,7 @@ function verifyCode(code, email) { 'Content-Type': 'application/json' }, body: JSON.stringify({ - 'code': code, 'email': email + code, email }) }; From 6f88b2aab34780885121cd7b7c8b79846edccc50 Mon Sep 17 00:00:00 2001 From: Morgan Prioux <68907081+MorganP-projects@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:38:00 +0100 Subject: [PATCH 05/11] Update src/components/anonymous/Login.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Quirrion <77339872+squirrion@users.noreply.github.com> --- src/components/anonymous/Login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/anonymous/Login.js b/src/components/anonymous/Login.js index c793c71..15b7039 100644 --- a/src/components/anonymous/Login.js +++ b/src/components/anonymous/Login.js @@ -28,7 +28,7 @@ function Login() { const errorEmail = useSelector(state => state.motDePasseOublie.error); const validEmail = useSelector(state => state.motDePasseOublie.success); const loading = useSelector(state => state.motDePasseOublie?.loading); - const messageCodeVerified = useSelector(state => state.authentication.messageCodeVerified); + const messageCodeVerified = useSelector(state => state.authentication?.messageCodeVerified); const dispatch = useDispatch(); const location = useLocation(); From 077591e4b872ffd7259375ed54f430f5388ca74c Mon Sep 17 00:00:00 2001 From: Morgan Prioux <68907081+MorganP-projects@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:39:18 +0100 Subject: [PATCH 06/11] Update src/components/anonymous/ModalVerifyCode.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Quirrion <77339872+squirrion@users.noreply.github.com> --- src/components/anonymous/ModalVerifyCode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/anonymous/ModalVerifyCode.js b/src/components/anonymous/ModalVerifyCode.js index aebe811..1927bce 100644 --- a/src/components/anonymous/ModalVerifyCode.js +++ b/src/components/anonymous/ModalVerifyCode.js @@ -14,7 +14,7 @@ const ModalVerifyCode = ({ setShowModalVerifyCode, email }) => { } function handleChange(e) { - setCode(e.target.value); + setCode(e.target?.value); } useEffect(() => { From ae2528628e8abea2eb4e18fcd2dd92b1243d822a Mon Sep 17 00:00:00 2001 From: morgan Date: Wed, 10 Jan 2024 10:44:50 +0100 Subject: [PATCH 07/11] retour de commentaire --- src/services/user.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/user.service.js b/src/services/user.service.js index f8b99f2..86e3e18 100644 --- a/src/services/user.service.js +++ b/src/services/user.service.js @@ -134,7 +134,7 @@ function handleResponse(response) { if (data?.data?.resetPasswordCnil && data.message === 'RESET_PASSWORD_CNIL') { return Promise.reject({ resetPasswordCnil: true }); } - if (data?.data?.attemptFail && (data.message === 'ERROR_ATTEMPT_LOGIN' || data.message === 'ERROR_ATTEMPT_LOGIN_BLOCKED')) { + if (data?.data?.attemptFail && (data.message === 'ERROR_ATTEMPT_LOGIN')) { return Promise.reject({ attemptFail: data?.data?.attemptFail }); } if (data?.data?.openPopinVerifyCode && data.message === 'PROCESS_LOGIN_UNBLOCKED') { From 1b930359b70a2c762c1625e10355c91eba74bbcf Mon Sep 17 00:00:00 2001 From: morgan Date: Wed, 10 Jan 2024 10:48:55 +0100 Subject: [PATCH 08/11] react 17.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7f1b50..3490ee6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dayjs": "^1.11.9", "downloadjs": "^1.4.7", "prop-types": "^15.8.1", - "react": "^18.2.0", + "react": "^17.0.2", "react-datepicker": "^4.16.0", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", From 7bd6621457c3bfc0957a868eb855ef3a06b5c5b8 Mon Sep 17 00:00:00 2001 From: morgan Date: Wed, 10 Jan 2024 11:07:32 +0100 Subject: [PATCH 09/11] remettre react 18 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3490ee6..1047e12 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,13 @@ "version": "0.1.0", "private": true, "dependencies": { - "@gouvfr/dsfr": "^1.9.0", + "@gouvfr/dsfr": "^1.11.0", "@reduxjs/toolkit": "^1.9.5", "axios": "^1.4.0", "dayjs": "^1.11.9", "downloadjs": "^1.4.7", "prop-types": "^15.8.1", - "react": "^17.0.2", + "react": "^18.2.0", "react-datepicker": "^4.16.0", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", From 62cc8172e50606bbbeffc585f10865f42194b607 Mon Sep 17 00:00:00 2001 From: morgan Date: Wed, 10 Jan 2024 11:31:20 +0100 Subject: [PATCH 10/11] suppression du passage de l'erreur par react-flash-message --- package.json | 1 - src/actions/user.actions.js | 5 +++++ src/components/anonymous/Login.js | 18 ++++++++++-------- src/reducers/authenticationReducer.js | 6 +++++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 1047e12..797e83a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "react-datepicker": "^4.16.0", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", - "react-flash-message": "^1.0.8", "react-loader-spinner": "^5.3.4", "react-pluralize": "^1.6.3", "react-redux": "^8.1.2", diff --git a/src/actions/user.actions.js b/src/actions/user.actions.js index 6a1a8b8..a0552af 100644 --- a/src/actions/user.actions.js +++ b/src/actions/user.actions.js @@ -3,6 +3,7 @@ import { userService } from '../services/user.service.js'; export const userActions = { login, logout, + clearErrorConnexion, verifyToken, verifyPrefetToken, choosePassword, @@ -53,6 +54,10 @@ function logout() { return { type: 'LOGOUT' }; } +function clearErrorConnexion() { + return { type: 'CLEAR_ERROR' }; +} + function verifyToken(token) { return dispatch => { dispatch(request(token)); diff --git a/src/components/anonymous/Login.js b/src/components/anonymous/Login.js index 15b7039..4aee3cb 100644 --- a/src/components/anonymous/Login.js +++ b/src/components/anonymous/Login.js @@ -1,7 +1,6 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; -import FlashMessage from 'react-flash-message'; import Pluralize from 'react-pluralize'; import { alerteEtSpinnerActions, userActions } from '../../actions'; import Header from '../common/Header'; @@ -76,17 +75,20 @@ function Login() { } }, [loading]); + useEffect(() => { + if (messageCodeVerified) { + dispatch(userActions.clearErrorConnexion()); + dispatch(alerteEtSpinnerActions.getMessageAlerte({ + type: 'success', + message: messageCodeVerified, + status: null, description: null + })); + } + }, [messageCodeVerified]); return (
- {messageCodeVerified && - -

- {messageCodeVerified} -

-
- } {showModalResetPassword && diff --git a/src/reducers/authenticationReducer.js b/src/reducers/authenticationReducer.js index 701a208..f9f3f53 100644 --- a/src/reducers/authenticationReducer.js +++ b/src/reducers/authenticationReducer.js @@ -1,5 +1,5 @@ let user = JSON.parse(localStorage.getItem('user')); -const initialState = user ? { loggedIn: true, user } : {}; +const initialState = user ? { loggedIn: true, user, error: null } : {}; export default function authentication(state = initialState, action) { switch (action.type) { @@ -17,6 +17,10 @@ export default function authentication(state = initialState, action) { return { error: action.error }; + case 'CLEAR_ERROR': + return { + error: null + }; case 'LOGOUT': return {}; case 'VERIFY_CODE_CONNEXION_REQUEST': From 7fca6dcc3eefa1825fc8d70b3c6084182fb8fc55 Mon Sep 17 00:00:00 2001 From: morgan Date: Wed, 10 Jan 2024 11:37:20 +0100 Subject: [PATCH 11/11] suppression de pluralize, pas compatible --- package.json | 1 - src/components/anonymous/Login.js | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 797e83a..a6893e1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", "react-loader-spinner": "^5.3.4", - "react-pluralize": "^1.6.3", "react-redux": "^8.1.2", "react-router-dom": "^6.14.2", "react-scripts": "5.0.1", diff --git a/src/components/anonymous/Login.js b/src/components/anonymous/Login.js index 4aee3cb..40b7414 100644 --- a/src/components/anonymous/Login.js +++ b/src/components/anonymous/Login.js @@ -1,7 +1,6 @@ import React, { useState, useEffect } from 'react'; import { Link, useLocation } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; -import Pluralize from 'react-pluralize'; import { alerteEtSpinnerActions, userActions } from '../../actions'; import Header from '../common/Header'; import ModalResetPassword from './ModalResetPassword'; @@ -130,12 +129,8 @@ function Login() {
{error?.attemptFail < 3 &&
Erreur de mot de passe, il ne vous reste plus que  - .
+ {countAttempt} {countAttempt > 1 ? 'essais' : 'essai' }. +
} {error?.attemptFail === 3 &&
Votre compte est bloqué pour les 10 prochaines minutes.