// 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: '' }; this.handleSubmit = this.handleSubmit.bind(this); this.handleEmailChange = this.handleEmailChange.bind(this); this.handlePasswordChange = this.handlePasswordChange.bind(this); } componentDidMount() { let 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 { this.props.onRequest('email', this.state.email.trim()); } } handleEmailChange(e) { this.setState({email: e.target.value}); } handlePasswordChange(e) { this.setState({password: e.target.value}); } render() { let reset = (this.state.token && this.state.scheme); return (
{reset ? { (placeholder) => } : <> { (placeholder) => } }
); } }