Remove :server.name for custom servers

Custom servers may not be configured such that their domain name === domain part.
This commit is contained in:
Luke Barnard 2017-04-21 16:09:11 +01:00
parent 2b9cb999ba
commit 9c4c706120
2 changed files with 20 additions and 3 deletions

View file

@ -230,6 +230,12 @@ module.exports = React.createClass({
switch (step) {
case 'm.login.password':
const PasswordLogin = sdk.getComponent('login.PasswordLogin');
// HSs that are not matrix.org may not be configured to have their
// domain name === domain part.
let hsDomain = url.parse(this.state.enteredHomeserverUrl).hostname;
if (hsDomain !== 'matrix.org') {
hsDomain = null;
}
return (
<PasswordLogin
onSubmit={this.onPasswordLogin}
@ -241,7 +247,7 @@ module.exports = React.createClass({
onPhoneNumberChanged={this.onPhoneNumberChanged}
onForgotPasswordClick={this.props.onForgotPasswordClick}
loginIncorrect={this.state.loginIncorrect}
hsDomain={url.parse(this.state.enteredHomeserverUrl).hostname}
hsDomain={hsDomain}
/>
);
case 'm.login.cas':

View file

@ -118,10 +118,21 @@ class PasswordLogin extends React.Component {
autoFocus
/>;
case PasswordLogin.LOGIN_FIELD_MXID:
const mxidInputClasses = classNames({
"mx_Login_field": true,
"mx_Login_username": true,
"mx_Login_field_has_suffix": Boolean(this.props.hsDomain),
});
let suffix = null;
if (this.props.hsDomain) {
suffix = <div className="mx_Login_username_suffix">
:{this.props.hsDomain}
</div>;
}
return <div className="mx_Login_username_group">
<div className="mx_Login_username_prefix">@</div>
<input
className="mx_Login_field mx_Login_username"
className={mxidInputClasses}
key="username_input"
type="text"
name="username" // make it a little easier for browser's remember-password
@ -130,7 +141,7 @@ class PasswordLogin extends React.Component {
value={this.state.username}
autoFocus
/>
<div className="mx_Login_username_suffix">:{this.props.hsDomain}</div>
{suffix}
</div>;
case PasswordLogin.LOGIN_FIELD_PHONE:
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');