IO-761 User Reset updates
This commit is contained in:
@@ -4,7 +4,10 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import ImEXOnlineLogo from "../../assets/logo192.png";
|
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 { selectPasswordReset } from "../../redux/user/user.selectors";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import "./user-request-pw-reset.styles.scss";
|
import "./user-request-pw-reset.styles.scss";
|
||||||
@@ -14,9 +17,14 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
});
|
});
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
sendPasswordReset: (email) => dispatch(sendPasswordReset(email)),
|
sendPasswordReset: (email) => dispatch(sendPasswordReset(email)),
|
||||||
|
sendPasswordResetAgain: (email) => dispatch(sendPasswordResetAgain(email)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export function UserRequestResetPw({ passwordReset, sendPasswordReset }) {
|
export function UserRequestResetPw({
|
||||||
|
passwordReset,
|
||||||
|
sendPasswordReset,
|
||||||
|
sendPasswordResetAgain,
|
||||||
|
}) {
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
try {
|
try {
|
||||||
sendPasswordReset(values.email);
|
sendPasswordReset(values.email);
|
||||||
@@ -35,7 +43,8 @@ export function UserRequestResetPw({ passwordReset, sendPasswordReset }) {
|
|||||||
extra={[
|
extra={[
|
||||||
<Button
|
<Button
|
||||||
key="send-again"
|
key="send-again"
|
||||||
onClick={() => sendPasswordReset(passwordReset.email)}
|
onClick={() => sendPasswordResetAgain(passwordReset.email)}
|
||||||
|
loading={passwordReset.loading}
|
||||||
>
|
>
|
||||||
{t("general.labels.sendagain")}
|
{t("general.labels.sendagain")}
|
||||||
</Button>,
|
</Button>,
|
||||||
@@ -68,7 +77,12 @@ export function UserRequestResetPw({ passwordReset, sendPasswordReset }) {
|
|||||||
{passwordReset.error ? (
|
{passwordReset.error ? (
|
||||||
<AlertComponent message={passwordReset.error} type="warning" />
|
<AlertComponent message={passwordReset.error} type="warning" />
|
||||||
) : null}
|
) : null}
|
||||||
<Button className="login-btn" type="primary" htmlType="submit">
|
<Button
|
||||||
|
className="login-btn"
|
||||||
|
type="primary"
|
||||||
|
htmlType="submit"
|
||||||
|
loading={passwordReset.loading}
|
||||||
|
>
|
||||||
{t("general.actions.submit")}
|
{t("general.actions.submit")}
|
||||||
</Button>
|
</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ export const sendPasswordReset = (email) => ({
|
|||||||
type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START,
|
type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START,
|
||||||
payload: email,
|
payload: email,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const sendPasswordResetAgain = (email) => ({
|
||||||
|
type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START_AGAIN,
|
||||||
|
payload: email,
|
||||||
|
});
|
||||||
|
|
||||||
export const sendPasswordResetFailure = (error) => ({
|
export const sendPasswordResetFailure = (error) => ({
|
||||||
type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_FAILURE,
|
type: UserActionTypes.SEND_PASSWORD_RESET_EMAIL_FAILURE,
|
||||||
payload: error,
|
payload: error,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const INITIAL_STATE = {
|
|||||||
email: null,
|
email: null,
|
||||||
error: null,
|
error: null,
|
||||||
success: false,
|
success: false,
|
||||||
|
loading: false,
|
||||||
},
|
},
|
||||||
authLevel: 0,
|
authLevel: 0,
|
||||||
};
|
};
|
||||||
@@ -33,6 +34,17 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
|||||||
email: action.payload,
|
email: action.payload,
|
||||||
error: null,
|
error: null,
|
||||||
success: false,
|
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:
|
case UserActionTypes.VALIDATE_PASSWORD_RESET_FAILURE:
|
||||||
@@ -42,7 +54,11 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
|||||||
case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_SUCCESS:
|
case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_SUCCESS:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
passwordreset: { ...state.passwordreset, success: true },
|
passwordreset: {
|
||||||
|
...state.passwordreset,
|
||||||
|
success: true,
|
||||||
|
loading: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
case UserActionTypes.SIGN_IN_SUCCESS:
|
case UserActionTypes.SIGN_IN_SUCCESS:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ export function* onSendPasswordResetStart() {
|
|||||||
UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START,
|
UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START,
|
||||||
sendPasswordResetEmail
|
sendPasswordResetEmail
|
||||||
);
|
);
|
||||||
|
yield takeLatest(
|
||||||
|
UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START_AGAIN,
|
||||||
|
sendPasswordResetEmail
|
||||||
|
);
|
||||||
}
|
}
|
||||||
export function* sendPasswordResetEmail({ payload }) {
|
export function* sendPasswordResetEmail({ payload }) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ const UserActionTypes = {
|
|||||||
SET_INSTANCE_CONFLICT: "SET_INSTANCE_CONFLICT",
|
SET_INSTANCE_CONFLICT: "SET_INSTANCE_CONFLICT",
|
||||||
SET_LOCAL_FINGERPRINT: "SET_LOCAL_FINGERPRINT",
|
SET_LOCAL_FINGERPRINT: "SET_LOCAL_FINGERPRINT",
|
||||||
SEND_PASSWORD_RESET_EMAIL_START: "SEND_PASSWORD_RESET_EMAIL_START",
|
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_FAILURE: "SEND_PASSWORD_RESET_EMAIL_FAILURE",
|
||||||
SEND_PASSWORD_RESET_EMAIL_SUCCESS: "SEND_PASSWORD_RESET_EMAIL_SUCCESS",
|
SEND_PASSWORD_RESET_EMAIL_SUCCESS: "SEND_PASSWORD_RESET_EMAIL_SUCCESS",
|
||||||
VALIDATE_PASSWORD_RESET_START: "VALIDATE_PASSWORD_RESET_START",
|
VALIDATE_PASSWORD_RESET_START: "VALIDATE_PASSWORD_RESET_START",
|
||||||
|
|||||||
Reference in New Issue
Block a user