SecurityForm: Respond to submit

This commit is contained in:
Alex Gleason 2020-06-05 14:45:00 -05:00
parent 1076788add
commit 91d511c4b9
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 3 additions and 0 deletions

View file

@ -15,6 +15,7 @@ export function changeEmail(email, password) {
email, email,
password, password,
}).then(response => { }).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 }); dispatch({ type: CHANGE_EMAIL_SUCCESS, email, response });
}).catch(error => { }).catch(error => {
dispatch({ type: CHANGE_EMAIL_FAIL, email, error, skipAlert: true }); dispatch({ type: CHANGE_EMAIL_FAIL, email, error, skipAlert: true });

View file

@ -43,8 +43,10 @@ class Security extends ImmutablePureComponent {
const { email, password } = this.state; const { email, password } = this.state;
const { dispatch, intl } = this.props; const { dispatch, intl } = this.props;
dispatch(changeEmail(email, password)).then(() => { dispatch(changeEmail(email, password)).then(() => {
this.setState({ email: '', password: '' }); // TODO: Maybe redirect user
dispatch(showAlert('', intl.formatMessage(messages.updateEmailSuccess))); dispatch(showAlert('', intl.formatMessage(messages.updateEmailSuccess)));
}).catch(error => { }).catch(error => {
this.setState({ password: '' });
dispatch(showAlert('', intl.formatMessage(messages.updateEmailFail))); dispatch(showAlert('', intl.formatMessage(messages.updateEmailFail)));
}); });
} }