// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import $ from 'jquery'; import ReactDOM from 'react-dom'; import * as Utils from 'utils/utils.jsx'; import client from 'utils/web_client.jsx'; import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; import React from 'react'; import {Link} from 'react-router/es6'; class PasswordResetSendLink extends React.Component { constructor(props) { super(props); this.handleSendLink = this.handleSendLink.bind(this); this.state = { error: '', updateText: '' }; } handleSendLink(e) { e.preventDefault(); var email = ReactDOM.findDOMNode(this.refs.email).value.trim().toLowerCase(); if (!email || !Utils.isEmail(email)) { this.setState({ error: ( ) }); return; } // End of error checking clear error this.setState({ error: '' }); client.sendPasswordReset( email, () => { this.setState({ error: null, updateText: (
) }); $(ReactDOM.findDOMNode(this.refs.reset_form)).hide(); }, (err) => { this.setState({ error: err.message, update_text: null }); } ); } render() { var error = null; if (this.state.error) { error =
; } var formClass = 'form-group'; if (error) { formClass += ' has-error'; } return (

{this.state.updateText}

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