From 91d511c4b9b19d42288d6f23dd62a10922a1b0b8 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 5 Jun 2020 14:45:00 -0500 Subject: [PATCH] SecurityForm: Respond to submit --- app/soapbox/actions/security.js | 1 + app/soapbox/features/security/index.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/soapbox/actions/security.js b/app/soapbox/actions/security.js index 0df6b9fe6..504cfc8f0 100644 --- a/app/soapbox/actions/security.js +++ b/app/soapbox/actions/security.js @@ -15,6 +15,7 @@ export function changeEmail(email, password) { email, password, }).then(response => { + if (response.data.error) throw response.data.error; // This endpoint returns HTTP 200 even on failure dispatch({ type: CHANGE_EMAIL_SUCCESS, email, response }); }).catch(error => { dispatch({ type: CHANGE_EMAIL_FAIL, email, error, skipAlert: true }); diff --git a/app/soapbox/features/security/index.js b/app/soapbox/features/security/index.js index 8c36a3e45..20e24b240 100644 --- a/app/soapbox/features/security/index.js +++ b/app/soapbox/features/security/index.js @@ -43,8 +43,10 @@ class Security extends ImmutablePureComponent { const { email, password } = this.state; const { dispatch, intl } = this.props; dispatch(changeEmail(email, password)).then(() => { + this.setState({ email: '', password: '' }); // TODO: Maybe redirect user dispatch(showAlert('', intl.formatMessage(messages.updateEmailSuccess))); }).catch(error => { + this.setState({ password: '' }); dispatch(showAlert('', intl.formatMessage(messages.updateEmailFail))); }); }