@shopgate/engage
Version:
Shopgate's ENGAGE library.
5 lines • 1.03 kB
JavaScript
import{PipelineRequest,LoadingProvider,EUSERNOTFOUND}from'@shopgate/engage/core';import{SHOPGATE_USER_RESET_PASSWORD,FORGOT_PASSWORD_PATTERN}from"../constants";import{requestResetPassword,receiveResetPassword,errorResetPassword}from"../action-creators";/**
* Sends a reset password pipeline request.
* @param {string} email The email for which the password shall be reset.
* @returns {Function} A redux thunk.
*/var resetPasswordAction=function resetPasswordAction(email){return function(dispatch){LoadingProvider.setLoading(FORGOT_PASSWORD_PATTERN);dispatch(requestResetPassword(email));var request=new PipelineRequest(SHOPGATE_USER_RESET_PASSWORD).setInput({email:email}).setTrusted().setErrorBlacklist([EUSERNOTFOUND]).dispatch();request.then(function(){dispatch(receiveResetPassword(email));LoadingProvider.resetLoading(FORGOT_PASSWORD_PATTERN);})["catch"](function(error){dispatch(errorResetPassword(email,error));LoadingProvider.resetLoading(FORGOT_PASSWORD_PATTERN);});return request;};};export default resetPasswordAction;