Update password change time immediately after successful update

This commit is contained in:
SleepWalker 2016-05-01 21:10:45 +03:00
parent e2a782f0b7
commit 8e90c4434e

View File

@ -25,6 +25,7 @@ class ChangePasswordPage extends Component {
import { connect } from 'react-redux';
import { routeActions } from 'react-router-redux';
import { register as registerPopup, create as createPopup } from 'components/ui/popup/actions';
import { updateUser } from 'components/user/actions';
function goToProfile() {
return routeActions.push('/');
@ -37,11 +38,17 @@ export default connect(null, {
dispatch(createPopup('requestPassword', (props) => {
return {
onSubmit: (password) => {
// TODO: hide this logic in action and do not forget to update password change time
// TODO: hide this logic in action
accounts.changePassword({
...data,
password
})
.then(() => {
dispatch(updateUser({
passwordChangedAt: Date.now() / 1000,
shouldChangePassword: false
}));
})
.then(props.onClose)
.then(() => dispatch(goToProfile()));
}