From b3003249ae2b463425e5b892a4e17fd15e904a08 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 17 Mar 2021 13:52:58 -0700 Subject: [PATCH] IO-761 User Reset updates --- .../user-request-reset-pw.component.jsx | 22 +++++++++++++++---- client/src/redux/user/user.actions.js | 6 +++++ client/src/redux/user/user.reducer.js | 18 ++++++++++++++- client/src/redux/user/user.sagas.js | 4 ++++ client/src/redux/user/user.types.js | 2 ++ 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/client/src/components/user-request-pw-reset/user-request-reset-pw.component.jsx b/client/src/components/user-request-pw-reset/user-request-reset-pw.component.jsx index 448993c18..62e8bc145 100644 --- a/client/src/components/user-request-pw-reset/user-request-reset-pw.component.jsx +++ b/client/src/components/user-request-pw-reset/user-request-reset-pw.component.jsx @@ -4,7 +4,10 @@ import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import ImEXOnlineLogo from "../../assets/logo192.png"; -import { sendPasswordReset } from "../../redux/user/user.actions"; +import { + sendPasswordReset, + sendPasswordResetAgain, +} from "../../redux/user/user.actions"; import { selectPasswordReset } from "../../redux/user/user.selectors"; import AlertComponent from "../alert/alert.component"; import "./user-request-pw-reset.styles.scss"; @@ -14,9 +17,14 @@ const mapStateToProps = createStructuredSelector({ }); const mapDispatchToProps = (dispatch) => ({ sendPasswordReset: (email) => dispatch(sendPasswordReset(email)), + sendPasswordResetAgain: (email) => dispatch(sendPasswordResetAgain(email)), }); -export function UserRequestResetPw({ passwordReset, sendPasswordReset }) { +export function UserRequestResetPw({ + passwordReset, + sendPasswordReset, + sendPasswordResetAgain, +}) { const handleFinish = (values) => { try { sendPasswordReset(values.email); @@ -35,7 +43,8 @@ export function UserRequestResetPw({ passwordReset, sendPasswordReset }) { extra={[ , @@ -68,7 +77,12 @@ export function UserRequestResetPw({ passwordReset, sendPasswordReset }) { {passwordReset.error ? ( ) : null} - diff --git a/client/src/redux/user/user.actions.js b/client/src/redux/user/user.actions.js index b7a3ca202..e3b7d076c 100644 --- a/client/src/redux/user/user.actions.js +++ b/client/src/redux/user/user.actions.js @@ -77,6 +77,12 @@ export const sendPasswordReset = (email) => ({ type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START, payload: email, }); + +export const sendPasswordResetAgain = (email) => ({ + type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START_AGAIN, + payload: email, +}); + export const sendPasswordResetFailure = (error) => ({ type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_FAILURE, payload: error, diff --git a/client/src/redux/user/user.reducer.js b/client/src/redux/user/user.reducer.js index 7d91454b7..398d61aab 100644 --- a/client/src/redux/user/user.reducer.js +++ b/client/src/redux/user/user.reducer.js @@ -13,6 +13,7 @@ const INITIAL_STATE = { email: null, error: null, success: false, + loading: false, }, authLevel: 0, }; @@ -33,6 +34,17 @@ const userReducer = (state = INITIAL_STATE, action) => { email: action.payload, error: null, success: false, + loading: true, + }, + }; + case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START_AGAIN: + return { + ...state, + passwordreset: { + email: action.payload, + error: null, + success: true, + loading: true, }, }; case UserActionTypes.VALIDATE_PASSWORD_RESET_FAILURE: @@ -42,7 +54,11 @@ const userReducer = (state = INITIAL_STATE, action) => { case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_SUCCESS: return { ...state, - passwordreset: { ...state.passwordreset, success: true }, + passwordreset: { + ...state.passwordreset, + success: true, + loading: false, + }, }; case UserActionTypes.SIGN_IN_SUCCESS: return { diff --git a/client/src/redux/user/user.sagas.js b/client/src/redux/user/user.sagas.js index 84e8178a6..1239800b0 100644 --- a/client/src/redux/user/user.sagas.js +++ b/client/src/redux/user/user.sagas.js @@ -170,6 +170,10 @@ export function* onSendPasswordResetStart() { UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START, sendPasswordResetEmail ); + yield takeLatest( + UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START_AGAIN, + sendPasswordResetEmail + ); } export function* sendPasswordResetEmail({ payload }) { try { diff --git a/client/src/redux/user/user.types.js b/client/src/redux/user/user.types.js index 1ee363c74..ddd8db75b 100644 --- a/client/src/redux/user/user.types.js +++ b/client/src/redux/user/user.types.js @@ -21,6 +21,8 @@ const UserActionTypes = { SET_INSTANCE_CONFLICT: "SET_INSTANCE_CONFLICT", SET_LOCAL_FINGERPRINT: "SET_LOCAL_FINGERPRINT", SEND_PASSWORD_RESET_EMAIL_START: "SEND_PASSWORD_RESET_EMAIL_START", + SEND_PASSWORD_RESET_EMAIL_START_AGAIN: + "SEND_PASSWORD_RESET_EMAIL_START_AGAIN", SEND_PASSWORD_RESET_EMAIL_FAILURE: "SEND_PASSWORD_RESET_EMAIL_FAILURE", SEND_PASSWORD_RESET_EMAIL_SUCCESS: "SEND_PASSWORD_RESET_EMAIL_SUCCESS", VALIDATE_PASSWORD_RESET_START: "VALIDATE_PASSWORD_RESET_START",