blob: 103a93bc68bcdba6561f9d2d2c6551efb5b9342a (
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var utils = require('../utils/utils.jsx');
var client = require('../utils/client.jsx');
var UserStore = require('../stores/user_store.jsx');
var FindTeamDomain = React.createClass({
handleSubmit: function(e) {
e.preventDefault();
var state = { }
var domain = this.refs.domain.getDOMNode().value.trim();
if (!domain) {
state.server_error = "A domain is required"
this.setState(state);
return;
}
state.server_error = "";
this.setState(state);
client.findTeamByDomain(domain,
function(data) {
console.log(data);
if (data) {
window.location.href = window.location.protocol + "//" + domain + "." + utils.getDomainWithOutSub();
}
else {
this.state.server_error = "We couldn't find your " + strings.TeamPlural + ".";
this.setState(this.state);
}
}.bind(this),
function(err) {
this.state.server_error = err.message;
this.setState(this.state);
}.bind(this)
);
},
getInitialState: function() {
return { };
},
render: function() {
var server_error = this.state.server_error ? <label className="control-label">{this.state.server_error}</label> : null;
return (
<div className="signup-team__container">
<div>
<span className="signup-team__name">{ config.SiteName }</span>
<br/>
<span className="signup-team__subdomain">Enter your {strings.TeamPlural} domain.</span>
<br/>
<br/>
</div>
<form onSubmit={this.handleSubmit}>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
{ server_error }
<input type="text" className="form-control" name="domain" ref="domain" placeholder="teamdomain" />
</div>
<div className="form-group">
<button type="submit" className="btn btn-primary">Continue</button>
</div>
<div>
<span>Don't remember your {strings.TeamPlural} domain? <a href="/find_team">Find it here</a></span>
</div>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<div>
<span>{"Want to create your own " + strings.Team + "?"} <a href={utils.getHomeLink()} className="signup-team-login">Sign up now</a></span>
</div>
</form>
</div>
);
}
});
module.exports = React.createClass({
handleSubmit: function(e) {
e.preventDefault();
var state = { }
var domain = this.refs.domain.getDOMNode().value.trim();
if (!domain) {
state.server_error = "A domain is required"
this.setState(state);
return;
}
var email = this.refs.email.getDOMNode().value.trim();
if (!email) {
state.server_error = "An email is required"
this.setState(state);
return;
}
var password = this.refs.password.getDOMNode().value.trim();
if (!password) {
state.server_error = "A password is required"
this.setState(state);
return;
}
state.server_error = "";
this.setState(state);
client.loginByEmail(domain, email, password,
function(data) {
UserStore.setLastDomain(domain);
UserStore.setLastEmail(email);
UserStore.setCurrentUser(data);
var redirect = utils.getUrlParameter("redirect");
if (redirect) {
window.location.href = decodeURI(redirect);
} else {
window.location.href = '/channels/town-square';
}
}.bind(this),
function(err) {
if (err.message == "Login failed because email address has not been verified") {
window.location.href = '/verify?domain=' + encodeURIComponent(domain) + '&email=' + encodeURIComponent(email);
return;
}
state.server_error = err.message;
this.valid = false;
this.setState(state);
}.bind(this)
);
},
getInitialState: function() {
return { };
},
render: function() {
var server_error = this.state.server_error ? <label className="control-label">{this.state.server_error}</label> : null;
var priorEmail = UserStore.getLastEmail() !== "undefined" ? UserStore.getLastEmail() : ""
var emailParam = utils.getUrlParameter("email");
if (emailParam) {
priorEmail = decodeURIComponent(emailParam);
}
var subDomainClass = "form-control hidden";
var subDomain = utils.getSubDomain();
if (utils.isTestDomain()) {
subDomainClass = "form-control";
subDomain = UserStore.getLastDomain();
} else if (subDomain == "") {
return (<FindTeamDomain />);
}
return (
<div className="signup-team__container">
<div>
<span className="signup-team__name">{ subDomain }</span>
<br/>
<span className="signup-team__subdomain">{ utils.getDomainWithOutSub() }</span>
<br/>
<br/>
</div>
<form onSubmit={this.handleSubmit}>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
{ server_error }
<input type="text" className={subDomainClass} name="domain" defaultValue={subDomain} ref="domain" placeholder="Domain" />
</div>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
<input type="email" className="form-control" name="email" defaultValue={priorEmail} ref="email" placeholder="Email" />
</div>
<div className={server_error ? 'form-group has-error' : 'form-group'}>
<input type="password" className="form-control" name="password" ref="password" placeholder="Password" />
</div>
<div className="form-group">
<button type="submit" className="btn btn-primary">Sign in</button>
</div>
<div className="form-group form-group--small">
<span><a href="/find_team">{"Find other " + strings.TeamPlural}</a></span>
</div>
<div className="form-group">
<a href="/reset_password">I forgot my password</a>
</div>
<div className="external-link">
<span>{"Want to create your own " + strings.Team + "?"} <a href={utils.getHomeLink()} className="signup-team-login">Sign up now</a></span>
</div>
</form>
</div>
);
}
});
|