// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import ReactDOM from 'react-dom'; import Client from 'client/web_client.jsx'; import * as Utils from 'utils/utils.jsx'; import Constants from 'utils/constants.jsx'; import {FormattedMessage} from 'react-intl'; import {browserHistory} from 'react-router/es6'; import React from 'react'; class PasswordResetForm extends React.Component { constructor(props) { super(props); this.handlePasswordReset = this.handlePasswordReset.bind(this); this.state = {}; } handlePasswordReset(e) { e.preventDefault(); const password = ReactDOM.findDOMNode(this.refs.password).value; if (!password || password.length < Constants.MIN_PASSWORD_LENGTH) { this.setState({ error: ( ) }); return; } this.setState({ error: null }); Client.resetPassword( this.props.location.query.code, password, () => { this.setState({error: null}); browserHistory.push('/login?extra=' + Constants.PASSWORD_CHANGE); }, (err) => { this.setState({error: err.message}); } ); } render() { var error = null; if (this.state.error) { error = (
); } var formClass = 'form-group'; if (error) { formClass += ' has-error'; } return (

{error}
); } } PasswordResetForm.defaultProps = { }; PasswordResetForm.propTypes = { params: React.PropTypes.object.isRequired, location: React.PropTypes.object.isRequired }; export default PasswordResetForm;