#248: Properly handle password confirm in profile form. Fixes sentry/#36

This commit is contained in:
SleepWalker 2017-01-02 15:39:34 +02:00
parent 26caa13b5f
commit 848d33c195
3 changed files with 21 additions and 6 deletions

View File

@ -76,7 +76,7 @@ function restoreScroll() {
const viewPort = document.body;
if (!viewPort) {
console.log('Can not find viewPort element');
console.log('Can not find viewPort element'); // eslint-disable-line
return;
}

View File

@ -1,5 +1,7 @@
import React, { Component, PropTypes } from 'react';
import logger from 'services/logger';
import { FooterMenu } from 'components/footerMenu';
import styles from './profile.scss';
@ -79,6 +81,13 @@ export default connect(null, {
}
})
.then((resp) => !resp.requirePassword || requestPassword(form))
.catch((resp) => {
if (!resp || !resp.errors) {
logger.warn('Unexpected profile editing error', {
resp
});
}
})
.finally(() => form.endLoading());
function requestPassword(form) {
@ -88,15 +97,15 @@ export default connect(null, {
const onSubmit = () => {
form.beginLoading();
sendData()
.then(resolve)
.then(props.onClose)
.catch((resp) => {
if (resp.errors) {
form.setErrors(resp.errors);
} else {
return Promise.reject(resp);
}
return Promise.reject(resp);
})
.then(resolve)
.then(props.onClose)
.finally(() => form.endLoading());
};

View File

@ -23,7 +23,13 @@ const logger = {
window.addEventListener('unhandledrejection', (event) => {
const error = event.reason || {};
const message = error.message ? `: ${error.message}` : '';
let message = error.message || error;
if (typeof message === 'string') {
message = `: ${message}`;
} else {
message = '';
}
logger.info(`Unhandled rejection${message}`, {
error