summaryrefslogtreecommitdiffstats
path: root/webapp/components/password_reset_form.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-14 08:50:46 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-16 18:02:55 -0400
commit12896bd23eeba79884245c1c29fdc568cf21a7fa (patch)
tree4e7f83d3e2564b9b89d669e9f7905ff11768b11a /webapp/components/password_reset_form.jsx
parent29fe6a3d13c9c7aa490fffebbe5d1b5fdf1e3090 (diff)
downloadchat-12896bd23eeba79884245c1c29fdc568cf21a7fa.tar.gz
chat-12896bd23eeba79884245c1c29fdc568cf21a7fa.tar.bz2
chat-12896bd23eeba79884245c1c29fdc568cf21a7fa.zip
Converting to Webpack. Stage 1.
Diffstat (limited to 'webapp/components/password_reset_form.jsx')
-rw-r--r--webapp/components/password_reset_form.jsx132
1 files changed, 132 insertions, 0 deletions
diff --git a/webapp/components/password_reset_form.jsx b/webapp/components/password_reset_form.jsx
new file mode 100644
index 000000000..863420902
--- /dev/null
+++ b/webapp/components/password_reset_form.jsx
@@ -0,0 +1,132 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import ReactDOM from 'react-dom';
+import * as Client from 'utils/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';
+
+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.trim();
+ if (!password || password.length < Constants.MIN_PASSWORD_LENGTH) {
+ this.setState({
+ error: (
+ <FormattedMessage
+ id='password_form.error'
+ defaultMessage='Please enter at least {chars} characters.'
+ chars={Constants.MIN_PASSWORD_LENGTH}
+ />
+ )
+ });
+ return;
+ }
+
+ this.setState({
+ error: null
+ });
+
+ const data = {};
+ data.new_password = password;
+ data.hash = this.props.location.query.h;
+ data.data = this.props.location.query.d;
+ data.name = this.props.params.team;
+
+ Client.resetPassword(data,
+ () => {
+ this.setState({error: null});
+ browserHistory.push('/' + this.props.params.team + '/login');
+ },
+ (err) => {
+ this.setState({error: err.message});
+ }
+ );
+ }
+ render() {
+ var error = null;
+ if (this.state.error) {
+ error = (
+ <div className='form-group has-error'>
+ <label className='control-label'>
+ {this.state.error}
+ </label>
+ </div>
+ );
+ }
+
+ var formClass = 'form-group';
+ if (error) {
+ formClass += ' has-error';
+ }
+
+ return (
+ <div className='col-sm-12'>
+ <div className='signup-team__container'>
+ <h3>
+ <FormattedMessage
+ id='password_form.title'
+ defaultMessage='Password Reset'
+ />
+ </h3>
+ <form onSubmit={this.handlePasswordReset}>
+ <p>
+ <FormattedMessage
+ id='password_form.enter'
+ defaultMessage='Enter a new password for your {siteName} account.'
+ values={{
+ siteName: global.window.mm_config.SiteName
+ }}
+ />
+ </p>
+ <div className={formClass}>
+ <input
+ type='password'
+ className='form-control'
+ name='password'
+ ref='password'
+ placeholder={Utils.localizeMessage(
+ 'password_form.pwd',
+ 'Password'
+ )}
+ spellCheck='false'
+ />
+ </div>
+ {error}
+ <button
+ type='submit'
+ className='btn btn-primary'
+ >
+ <FormattedMessage
+ id='password_form.change'
+ defaultMessage='Change my password'
+ />
+ </button>
+ </form>
+ </div>
+ </div>
+ );
+ }
+}
+
+PasswordResetForm.defaultProps = {
+};
+PasswordResetForm.propTypes = {
+ params: React.PropTypes.object.isRequired,
+ location: React.PropTypes.object.isRequired
+};
+
+export default PasswordResetForm;