2017-08-23 00:19:50 +05:30
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
2016-04-17 15:05:04 +05:30
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
|
|
|
import Helmet from 'react-helmet';
|
2019-12-08 00:32:00 +05:30
|
|
|
import {
|
|
|
|
Input,
|
|
|
|
Button,
|
|
|
|
Checkbox,
|
|
|
|
Form,
|
|
|
|
FormModel,
|
|
|
|
} from 'app/components/ui/form';
|
|
|
|
import { BackButton } from 'app/components/profile/ProfileForm';
|
|
|
|
|
|
|
|
import styles from 'app/components/profile/profileForm.scss';
|
2016-05-09 00:58:51 +05:30
|
|
|
import messages from './ChangePassword.intl.json';
|
2016-04-17 15:05:04 +05:30
|
|
|
|
|
|
|
export default class ChangePassword extends Component {
|
2019-11-27 14:33:32 +05:30
|
|
|
static displayName = 'ChangePassword';
|
2016-05-01 23:20:55 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
static propTypes = {
|
|
|
|
form: PropTypes.instanceOf(FormModel),
|
|
|
|
onSubmit: PropTypes.func.isRequired,
|
|
|
|
};
|
2016-05-01 23:20:55 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
static get defaultProps() {
|
|
|
|
return {
|
|
|
|
form: new FormModel(),
|
2016-05-01 23:20:55 +05:30
|
|
|
};
|
2019-11-27 14:33:32 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { form } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form onSubmit={this.onFormSubmit} form={form}>
|
|
|
|
<div className={styles.contentWithBackButton}>
|
|
|
|
<BackButton />
|
|
|
|
|
|
|
|
<div className={styles.form}>
|
|
|
|
<div className={styles.formBody}>
|
|
|
|
<Message {...messages.changePasswordTitle}>
|
|
|
|
{pageTitle => (
|
|
|
|
<h3 className={styles.title}>
|
|
|
|
<Helmet title={pageTitle} />
|
|
|
|
{pageTitle}
|
|
|
|
</h3>
|
|
|
|
)}
|
|
|
|
</Message>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<p className={styles.description}>
|
|
|
|
<Message {...messages.changePasswordDescription} />
|
|
|
|
<br />
|
|
|
|
<b>
|
|
|
|
<Message {...messages.achievementLossWarning} />
|
|
|
|
</b>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<Input
|
|
|
|
{...form.bindField('newPassword')}
|
|
|
|
type="password"
|
|
|
|
required
|
|
|
|
skin="light"
|
|
|
|
label={messages.newPasswordLabel}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<p className={styles.description}>
|
|
|
|
<Message {...messages.passwordRequirements} />
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<Input
|
|
|
|
{...form.bindField('newRePassword')}
|
|
|
|
type="password"
|
|
|
|
required
|
|
|
|
skin="light"
|
|
|
|
label={messages.repeatNewPasswordLabel}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<Checkbox
|
|
|
|
{...form.bindField('logoutAll')}
|
|
|
|
defaultChecked
|
|
|
|
skin="light"
|
|
|
|
label={messages.logoutOnAllDevices}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
color="green"
|
|
|
|
block
|
|
|
|
label={messages.changePasswordButton}
|
|
|
|
type="submit"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFormSubmit = () => {
|
|
|
|
const { form } = this.props;
|
|
|
|
|
|
|
|
this.props.onSubmit(form).catch(resp => {
|
|
|
|
if (resp.errors) {
|
|
|
|
form.setErrors(resp.errors);
|
|
|
|
} else {
|
|
|
|
return Promise.reject(resp);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2016-04-17 15:05:04 +05:30
|
|
|
}
|