// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. const Utils = require('../utils/utils.jsx'); var client = require('../utils/client.jsx'); export default class PasswordResetSendLink extends React.Component { constructor(props) { super(props); this.handleSendLink = this.handleSendLink.bind(this); this.state = {}; } handleSendLink(e) { e.preventDefault(); var state = {}; var email = React.findDOMNode(this.refs.email).value.trim().toLowerCase(); if (!email || !Utils.isEmail(email)) { state.error = 'Please enter a valid email address.'; this.setState(state); return; } state.error = null; this.setState(state); var data = {}; data.email = email; data.name = this.props.teamName; client.sendPasswordReset(data, function passwordResetSent() { this.setState({error: null, updateText:

A password reset link has been sent to {email} for your {this.props.teamDisplayName} team on {window.location.hostname}.

, moreUpdateText: 'Please check your inbox.'}); $(React.findDOMNode(this.refs.reset_form)).hide(); }.bind(this), function passwordResetFailedToSend(err) { this.setState({error: err.message, update_text: null, moreUpdateText: null}); }.bind(this) ); } render() { var updateText = null; if (this.state.updateText) { updateText =
{this.state.updateText}{this.state.moreUpdateText}
; } var error = null; if (this.state.error) { error =
; } var formClass = 'form-group'; if (error) { formClass += ' has-error'; } return (

Password Reset

{updateText}

{'To reset your password, enter the email address you used to sign up for ' + this.props.teamDisplayName + '.'}

{error}
); } } PasswordResetSendLink.defaultProps = { teamName: '', teamDisplayName: '' }; PasswordResetSendLink.propTypes = { teamName: React.PropTypes.string, teamDisplayName: React.PropTypes.string };