Skip to content

Commit 737fc74

Browse files
committed
Merge branch 'matthew/login' into matthew/userlist
2 parents e3798e1 + 027ab6e commit 737fc74

5 files changed

Lines changed: 57 additions & 39 deletions

File tree

‎skins/base/css/common.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ html {
8383
font-size: 16px;
8484
position: relative;
8585
border-radius: 8px;
86+
max-width: 75%;
8687
}
8788

8889
.mx_ImageView {

‎skins/base/css/templates/Login.css‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ limitations under the License.
1717
.mx_Login {
1818
width: 100%;
1919
height: 100%;
20-
display: -webkit-box;
21-
display: -moz-box;
22-
display: -ms-flexbox;
23-
display: -webkit-flex;
24-
display: flex;
25-
-webkit-align-items: center;
26-
align-items: center;
27-
-webkit-justify-content: center;
28-
justify-content: center;
2920
}
3021

3122
.mx_Login h2 {
@@ -37,6 +28,8 @@ limitations under the License.
3728

3829
.mx_Login_box {
3930
width: 300px;
31+
margin: auto;
32+
padding-top: 100px;
4033
}
4134

4235
.mx_Login_logo {
@@ -82,11 +75,19 @@ limitations under the License.
8275
opacity: 0.8;
8376
}
8477

78+
.mx_Login_loader {
79+
position: absolute;
80+
left: 50%;
81+
margin-top: 12px;
82+
}
83+
8584
.mx_Login_error {
8685
color: #ff2020;
8786
font-weight: bold;
8887
text-align: center;
89-
margin-bottom: 24px;
88+
height: 24px;
89+
margin-top: 12px;
90+
margin-bottom: 12px;
9091
}
9192

9293
.mx_Login_create:link {

‎skins/base/views/templates/Login.js‎

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,25 @@ module.exports = React.createClass({
7474
*/
7575
getFormVals: function() {
7676
return {
77-
'username': this.refs.user.getDOMNode().value,
78-
'password': this.refs.pass.getDOMNode().value
77+
'username': this.refs.user.getDOMNode().value.trim(),
78+
'password': this.refs.pass.getDOMNode().value.trim()
7979
};
8080
},
8181

8282
onHsUrlChanged: function() {
83-
this.customHsUrl = this.refs.serverConfig.getHsUrl();
84-
this.customIsUrl = this.refs.serverConfig.getIsUrl();
83+
var newHsUrl = this.refs.serverConfig.getHsUrl().trim();
84+
var newIsUrl = this.refs.serverConfig.getIsUrl().trim();
85+
86+
if (newHsUrl == this.customHsUrl &&
87+
newIsUrl == this.customIsUrl)
88+
{
89+
return;
90+
}
91+
else {
92+
this.customHsUrl = newHsUrl;
93+
this.customIsUrl = newIsUrl;
94+
}
95+
8596
MatrixClientPeg.replaceUsingUrls(
8697
this.getHsUrl(),
8798
this.getIsUrl()
@@ -93,23 +104,24 @@ module.exports = React.createClass({
93104
// XXX: HSes do not have to offer password auth, so we
94105
// need to update and maybe show a different component
95106
// when a new HS is entered.
96-
/*if (this.updateHsTimeout) {
107+
if (this.updateHsTimeout) {
97108
clearTimeout(this.updateHsTimeout);
98109
}
99110
var self = this;
100111
this.updateHsTimeout = setTimeout(function() {
101112
self.onHSChosen();
102-
}, 500);*/
113+
}, 1000);
103114
},
104115

105116
componentForStep: function(step) {
106117
switch (step) {
107118
case 'choose_hs':
119+
case 'fetch_stages':
108120
var serverConfigStyle = {};
109121
serverConfigStyle.display = this.state.serverConfigVisible ? 'block' : 'none';
110122
return (
111123
<div>
112-
<input className="mx_Login_checkbox" id="advanced" type="checkbox" value={this.state.serverConfigVisible} onChange={this.onServerConfigVisibleChange} />
124+
<input className="mx_Login_checkbox" id="advanced" type="checkbox" checked={this.state.serverConfigVisible} onChange={this.onServerConfigVisibleChange} />
113125
<label className="mx_Login_label" htmlFor="advanced">Use custom server options (advanced)</label>
114126
<div style={serverConfigStyle}>
115127
<ServerConfig ref="serverConfig"
@@ -126,7 +138,7 @@ module.exports = React.createClass({
126138
<form onSubmit={this.onUserPassEntered}>
127139
<input className="mx_Login_field" ref="user" type="text" value={this.state.username} onChange={this.onUsernameChanged} placeholder="Email or user name" /><br />
128140
<input className="mx_Login_field" ref="pass" type="password" value={this.state.password} onChange={this.onPasswordChanged} placeholder="Password" /><br />
129-
{this.componentForStep('choose_hs')}
141+
{ this.componentForStep('choose_hs') }
130142
<input className="mx_Login_submit" type="submit" value="Log in" />
131143
</form>
132144
</div>
@@ -143,20 +155,18 @@ module.exports = React.createClass({
143155
},
144156

145157
loginContent: function() {
146-
if (this.state.busy) {
147-
return (
148-
<Loader />
149-
);
150-
} else {
151-
return (
152-
<div>
153-
<h2>Sign in</h2>
154-
{this.componentForStep(this.state.step)}
155-
<div className="mx_Login_error">{this.state.errorText}</div>
156-
<a className="mx_Login_create" onClick={this.showRegister} href="#">Create a new account</a>
158+
var loader = this.state.busy ? <div className="mx_Login_loader"><Loader /></div> : null;
159+
return (
160+
<div>
161+
<h2>Sign in</h2>
162+
{this.componentForStep(this.state.step)}
163+
<div className="mx_Login_error">
164+
{ loader }
165+
{this.state.errorText}
157166
</div>
158-
);
159-
}
167+
<a className="mx_Login_create" onClick={this.showRegister} href="#">Create a new account</a>
168+
</div>
169+
);
160170
},
161171

162172
render: function() {

‎skins/base/views/templates/Register.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ module.exports = React.createClass({
4646

4747
getRegFormVals: function() {
4848
return {
49-
email: this.refs.email.getDOMNode().value,
50-
username: this.refs.username.getDOMNode().value,
51-
password: this.refs.password.getDOMNode().value,
52-
confirmPassword: this.refs.confirmPassword.getDOMNode().value
49+
email: this.refs.email.getDOMNode().value.trim(),
50+
username: this.refs.username.getDOMNode().value.trim(),
51+
password: this.refs.password.getDOMNode().value.trim(),
52+
confirmPassword: this.refs.confirmPassword.getDOMNode().value.trim()
5353
};
5454
},
5555

‎src/controllers/templates/Login.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
},
3636

3737
setStep: function(step) {
38-
this.setState({ step: step, errorText: '', busy: false });
38+
this.setState({ step: step, busy: false });
3939
},
4040

4141
onHSChosen: function() {
@@ -45,11 +45,14 @@ module.exports = {
4545
);
4646
this.setState({
4747
hs_url: this.getHsUrl(),
48-
is_url: this.getIsUrl()
48+
is_url: this.getIsUrl(),
4949
});
5050
this.setStep("fetch_stages");
5151
var cli = MatrixClientPeg.get();
52-
this.setState({busy: true});
52+
this.setState({
53+
busy: true,
54+
errorText: "",
55+
});
5356
var self = this;
5457
cli.loginFlows().done(function(result) {
5558
self.setState({
@@ -66,7 +69,10 @@ module.exports = {
6669

6770
onUserPassEntered: function(ev) {
6871
ev.preventDefault();
69-
this.setState({busy: true});
72+
this.setState({
73+
busy: true,
74+
errorText: "",
75+
});
7076
var self = this;
7177

7278
var formVals = this.getFormVals();

0 commit comments

Comments
 (0)