// A password reset form. import React from 'react'; import { FormattedMessage } from 'react-intl'; import VisiblePassword from '../widgets/visible-password.jsx'; import HashNavigation from '../lib/navigation.js'; export default class PasswordResetView extends React.PureComponent { constructor(props) { super(props); this.state = { email: '', password: '', sent: false }; this.handleSubmit = this.handleSubmit.bind(this); this.handleEmailChange = this.handleEmailChange.bind(this); this.handlePasswordChange = this.handlePasswordChange.bind(this); } componentDidMount() { const parsed = HashNavigation.parseUrlHash(window.location.hash); this.setState({token: parsed.params.token, scheme: parsed.params.scheme}); } handleSubmit(e) { e.preventDefault(); if (this.state.token) { this.props.onReset(this.state.scheme, this.state.password.trim(), this.state.token); } else if (this.state.sent) { this.props.onCancel(); } else { const email = this.state.email.trim(); this.setState({email: email}); this.props.onRequest('email', email).then(() => { this.setState({sent: true}); }); } } handleEmailChange(e) { this.setState({email: e.target.value}); } handlePasswordChange(e) { this.setState({password: e.target.value}); } render() { return (
{(this.state.token && this.state.scheme) ? { (placeholder) => } : this.state.sent ? <>
task_alt

{this.state.email} }} description="Notification that the email with password reset instructions has been sent" />
: <> { (placeholder) => } }
); } }