// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var client = require('../utils/client.jsx'); export default class PasswordResetForm extends React.Component { constructor(props) { super(props); this.handlePasswordReset = this.handlePasswordReset.bind(this); this.state = {}; } handlePasswordReset(e) { e.preventDefault(); var state = {}; var password = React.findDOMNode(this.refs.password).value.trim(); if (!password || password.length < 5) { state.error = 'Please enter at least 5 characters.'; this.setState(state); return; } state.error = null; this.setState(state); var data = {}; data.new_password = password; data.hash = this.props.hash; data.data = this.props.data; data.name = this.props.teamName; client.resetPassword(data, function resetSuccess() { this.setState({error: null, updateText: 'Your password has been updated successfully.'}); }.bind(this), function resetFailure(err) { this.setState({error: err.message, updateText: null}); }.bind(this) ); } render() { var updateText = null; if (this.state.updateText) { updateText =