blob: 1b579efbc03561eeee2f0e768950dd2d3ea41c5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var client = require('../utils/client.jsx');
import {config} from '../utils/config.js';
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 = <div className='form-group'><br/><label className='control-label reset-form'>{this.state.updateText} Click <a href={'/' + this.props.teamName + '/login'}>here</a> to log in.</label></div>;
}
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>Password Reset</h3>
<form onSubmit={this.handlePasswordReset}>
<p>{'Enter a new password for your ' + this.props.teamDisplayName + ' ' + config.SiteName + ' account.'}</p>
<div className={formClass}>
<input
type='password'
className='form-control'
name='password'
ref='password'
placeholder='Password'
/>
</div>
{error}
<button
type='submit'
className='btn btn-primary'
>
Change my password
</button>
{updateText}
</form>
</div>
</div>
);
}
}
PasswordResetForm.defaultProps = {
teamName: '',
teamDisplayName: '',
hash: '',
data: ''
};
PasswordResetForm.propTypes = {
teamName: React.PropTypes.string,
teamDisplayName: React.PropTypes.string,
hash: React.PropTypes.string,
data: React.PropTypes.string
};
|