diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index a1a44611f..e562fd29f 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -87,9 +87,9 @@ const forgotPassowordRequest = () => ({type: actions.FETCH_FORGOT_PASSWORD_REQUE const forgotPassowordSuccess = () => ({type: actions.FETCH_FORGOT_PASSWORD_SUCCESS}); const forgotPassowordFailure = () => ({type: actions.FETCH_FORGOT_PASSWORD_FAILURE}); -export const fetchForgotPassword = () => dispatch => { - dispatch(forgotPassowordRequest()); - fetch(`${base}/user/request-password-reset`, getInit('POST')) +export const fetchForgotPassword = email => dispatch => { + dispatch(forgotPassowordRequest(email)); + fetch(`${base}/user/request-password-reset`, getInit('POST', {email})) .then(handleResp) .then(() => dispatch(forgotPassowordSuccess())) .catch(error => dispatch(forgotPassowordFailure(error))); diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js index 3e454892f..343ac9c09 100644 --- a/client/coral-framework/reducers/auth.js +++ b/client/coral-framework/reducers/auth.js @@ -8,6 +8,8 @@ const initialState = Map({ showSignInDialog: false, view: 'SIGNIN', error: '', + passwordRequestSuccess: null, + passwordRequestFailure: null, successSignUp: false }); @@ -22,6 +24,8 @@ export default function auth (state = initialState, action) { showSignInDialog: false, view: 'SIGNIN', error: '', + passwordRequestFailure: null, + passwordRequestSuccess: null, successSignUp: false })); case actions.CHANGE_VIEW : @@ -70,6 +74,14 @@ export default function auth (state = initialState, action) { case actions.VALID_FORM: return state .set('error', ''); + case actions.FETCH_FORGOT_PASSWORD_SUCCESS: + return state + .set('passwordRequestFailure', null) + .set('passwordRequestSuccess', 'If you have a registered account, a password reset link was sent to that email'); + case actions.FETCH_FORGOT_PASSWORD_FAILURE: + return state + .set('passwordRequestFailure', 'There was an error sending your password reset email. Please try again soon!') + .set('passwordRequestSuccess', null); default : return state; } diff --git a/client/coral-sign-in/components/ForgotContent.js b/client/coral-sign-in/components/ForgotContent.js index 7214d2bb6..c9a99f6d7 100644 --- a/client/coral-sign-in/components/ForgotContent.js +++ b/client/coral-sign-in/components/ForgotContent.js @@ -5,25 +5,56 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations'; const lang = new I18n(translations); -const ForgotContent = ({changeView, ...props}) => ( -