2021-04-12 13:32:25 +00:00
|
|
|
import PATHS from "router/paths";
|
|
|
|
import { push } from "react-router-redux";
|
|
|
|
import { renderFlash } from "redux/nodes/notifications/actions";
|
|
|
|
import userActions from "redux/nodes/entities/users/actions";
|
2017-02-24 15:08:59 +00:00
|
|
|
|
|
|
|
const confirmEmailChange = (dispatch, token, user) => {
|
|
|
|
if (user && token) {
|
|
|
|
return dispatch(userActions.confirmEmailChange(user, token))
|
|
|
|
.then(() => {
|
|
|
|
dispatch(push(PATHS.USER_SETTINGS));
|
2021-04-12 13:32:25 +00:00
|
|
|
dispatch(renderFlash("success", "Email updated successfully!"));
|
2017-02-24 15:08:59 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
dispatch(push(PATHS.LOGIN));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
};
|
|
|
|
|
|
|
|
export default { confirmEmailChange };
|