2016-05-01 23:20:55 +05:30
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
|
|
|
import accounts from 'services/api/accounts';
|
2016-05-02 15:08:45 +05:30
|
|
|
import { FormModel } from 'components/ui/form';
|
2016-05-01 23:20:55 +05:30
|
|
|
import ChangePassword from 'components/profile/changePassword/ChangePassword';
|
|
|
|
|
|
|
|
class ChangePasswordPage extends Component {
|
|
|
|
static displayName = 'ChangePasswordPage';
|
|
|
|
|
|
|
|
static propTypes = {
|
2016-05-22 13:23:40 +05:30
|
|
|
updateUser: PropTypes.func.isRequired
|
2016-05-12 10:00:10 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
static contextTypes = {
|
2016-05-22 13:23:40 +05:30
|
|
|
onSubmit: PropTypes.func.isRequired,
|
|
|
|
goToProfile: PropTypes.func.isRequired
|
2016-05-01 23:20:55 +05:30
|
|
|
};
|
|
|
|
|
2016-05-02 14:50:50 +05:30
|
|
|
form = new FormModel();
|
|
|
|
|
2016-05-01 23:20:55 +05:30
|
|
|
render() {
|
|
|
|
return (
|
2016-05-02 14:50:50 +05:30
|
|
|
<ChangePassword onSubmit={this.onSubmit} form={this.form} />
|
2016-05-01 23:20:55 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-05-02 14:50:50 +05:30
|
|
|
onSubmit = () => {
|
2016-05-12 10:00:10 +05:30
|
|
|
const {form} = this;
|
|
|
|
this.context.onSubmit({
|
|
|
|
form,
|
|
|
|
sendData: () => accounts.changePassword(form.serialize())
|
|
|
|
}).then(() => {
|
|
|
|
this.props.updateUser({
|
|
|
|
passwordChangedAt: Date.now() / 1000,
|
|
|
|
shouldChangePassword: false
|
|
|
|
});
|
2016-05-22 13:23:40 +05:30
|
|
|
this.context.goToProfile();
|
2016-05-12 10:00:10 +05:30
|
|
|
});
|
2016-05-01 23:20:55 +05:30
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
2016-05-01 23:40:45 +05:30
|
|
|
import { updateUser } from 'components/user/actions';
|
2016-05-01 23:20:55 +05:30
|
|
|
|
|
|
|
export default connect(null, {
|
2016-05-12 10:00:10 +05:30
|
|
|
updateUser
|
2016-05-01 23:20:55 +05:30
|
|
|
})(ChangePasswordPage);
|