2016-02-13 20:58:47 +05:30
|
|
|
import React, { PropTypes } from 'react';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2016-01-19 11:47:21 +05:30
|
|
|
import Helmet from 'react-helmet';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
|
|
|
import buttons from 'components/ui/buttons.scss';
|
|
|
|
import icons from 'components/ui/icons.scss';
|
|
|
|
import { Input, Checkbox } from 'components/ui/Form';
|
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
import BaseAuthBody from './BaseAuthBody';
|
2016-01-19 11:47:21 +05:30
|
|
|
import styles from './password.scss';
|
|
|
|
import messages from './Password.messages';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
class Body extends BaseAuthBody {
|
|
|
|
static propTypes = {
|
|
|
|
...BaseAuthBody.propTypes,
|
|
|
|
login: PropTypes.func.isRequired,
|
|
|
|
logout: PropTypes.func.isRequired,
|
|
|
|
auth: PropTypes.shape({
|
|
|
|
error: PropTypes.string,
|
|
|
|
login: PropTypes.shape({
|
|
|
|
login: PropTypes.stirng,
|
|
|
|
password: PropTypes.stirng
|
|
|
|
})
|
|
|
|
})
|
|
|
|
};
|
2016-01-31 18:29:38 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
render() {
|
|
|
|
const {user} = this.props;
|
|
|
|
|
|
|
|
return (
|
2016-01-31 18:29:38 +05:30
|
|
|
<div>
|
2016-02-13 20:58:47 +05:30
|
|
|
{this.renderErrors()}
|
|
|
|
|
2016-01-31 18:29:38 +05:30
|
|
|
<div className={styles.miniProfile}>
|
|
|
|
<div className={styles.avatar}>
|
2016-02-13 20:58:47 +05:30
|
|
|
{user.avatar
|
|
|
|
? <img src={user.avatar} />
|
|
|
|
: <span className={icons.user} />
|
|
|
|
}
|
2016-01-31 18:29:38 +05:30
|
|
|
</div>
|
|
|
|
<div className={styles.email}>
|
2016-02-13 20:58:47 +05:30
|
|
|
{user.email || user.username}
|
2016-01-31 18:29:38 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
2016-02-13 20:58:47 +05:30
|
|
|
<Input {...this.bindField('password')}
|
|
|
|
icon="key"
|
|
|
|
type="password"
|
|
|
|
autoFocus
|
|
|
|
required
|
|
|
|
placeholder={messages.accountPassword}
|
|
|
|
/>
|
2016-01-31 18:29:38 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
<Checkbox {...this.bindField('rememberMe')} label={<Message {...messages.rememberMe} />} />
|
2016-01-31 18:29:38 +05:30
|
|
|
</div>
|
2016-02-13 20:58:47 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFormSubmit() {
|
|
|
|
this.props.login({
|
|
|
|
...this.serialize(),
|
|
|
|
login: this.props.user.email || this.props.user.username
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onGoBack() {
|
|
|
|
this.props.logout();
|
|
|
|
}
|
|
|
|
}
|
2016-01-31 18:29:38 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
export default function Password() {
|
|
|
|
var Title = () => ( // TODO: separate component for PageTitle
|
|
|
|
<Message {...messages.passwordTitle}>
|
|
|
|
{(msg) => <span>{msg}<Helmet title={msg} /></span>}
|
|
|
|
</Message>
|
|
|
|
);
|
|
|
|
Title.goBack = true;
|
|
|
|
|
|
|
|
return {
|
|
|
|
Title,
|
|
|
|
Body,
|
|
|
|
Footer: () => (
|
|
|
|
<button className={buttons.green} type="submit">
|
2016-01-31 18:29:38 +05:30
|
|
|
<Message {...messages.signInButton} />
|
|
|
|
</button>
|
|
|
|
),
|
|
|
|
Links: () => (
|
|
|
|
<a href="#">
|
|
|
|
<Message {...messages.forgotPassword} />
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
}
|