Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2972 from matrix-org/travis/wk/mxid
Browse files Browse the repository at this point in the history
Restore use of full mxid login
  • Loading branch information
turt2live authored May 16, 2019
2 parents f75dc9c + 1ea5b42 commit 3e10d3c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/components/structures/auth/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {_t, _td} from '../../../languageHandler';
import sdk from '../../../index';
import Login from '../../../Login';
import SdkConfig from '../../../SdkConfig';
import {messageForResourceLimitError} from '../../../utils/ErrorUtils';
import {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";
import { messageForResourceLimitError } from '../../../utils/ErrorUtils';
import AutoDiscoveryUtils, {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";

// For validating phone numbers without country codes
const PHONE_NUMBER_REGEX = /^[0-9()\-\s]*$/;
Expand Down Expand Up @@ -235,21 +235,25 @@ module.exports = React.createClass({
this.setState({ username: username });
},

onUsernameBlur: function(username) {
onUsernameBlur: async function(username) {
this.setState({
username: username,
busy: true, // unset later by the result of onServerConfigChange
errorText: null,
});
if (username[0] === "@" && false) { // TODO: TravisR - Restore this
if (username[0] === "@") {
const serverName = username.split(':').slice(1).join(':');
try {
// we have to append 'https://' to make the URL constructor happy
// otherwise we get things like 'protocol: matrix.org, pathname: 8448'
const url = new URL("https://" + serverName);
this._tryWellKnownDiscovery(url.hostname);
const result = await AutoDiscoveryUtils.validateServerName(serverName);
this.props.onServerConfigChange(result);
} catch (e) {
console.error("Problem parsing URL or unhandled error doing .well-known discovery:", e);
this.setState({errorText: _t("Failed to perform homeserver discovery")});

let message = _t("Failed to perform homeserver discovery");
if (e.translatedMessage) {
message = e.translatedMessage;
}
this.setState({errorText: message, busy: false});
}
}
},
Expand Down

0 comments on commit 3e10d3c

Please sign in to comment.