Avoid hsName for auth headers which can be outdated

`hsName` uses only the default HS, so that can easily be outdated if the HS URL
is customized.
pull/21833/head
J. Ryan Stinnett 2019-01-30 00:33:29 -06:00
parent f5e3b90fc3
commit cfe19d710b
5 changed files with 13 additions and 34 deletions

View File

@ -1892,7 +1892,6 @@ export default React.createClass({
idSid={this.state.register_id_sid} idSid={this.state.register_id_sid}
email={this.props.startingFragmentQueryParams.email} email={this.props.startingFragmentQueryParams.email}
referrer={this.props.startingFragmentQueryParams.referrer} referrer={this.props.startingFragmentQueryParams.referrer}
defaultServerName={this.getDefaultServerName()}
defaultServerDiscoveryError={this.state.defaultServerDiscoveryError} defaultServerDiscoveryError={this.state.defaultServerDiscoveryError}
defaultHsUrl={this.getDefaultHsUrl()} defaultHsUrl={this.getDefaultHsUrl()}
defaultIsUrl={this.getDefaultIsUrl()} defaultIsUrl={this.getDefaultIsUrl()}
@ -1932,7 +1931,6 @@ export default React.createClass({
<Login <Login
onLoggedIn={Lifecycle.setLoggedIn} onLoggedIn={Lifecycle.setLoggedIn}
onRegisterClick={this.onRegisterClick} onRegisterClick={this.onRegisterClick}
defaultServerName={this.getDefaultServerName()}
defaultServerDiscoveryError={this.state.defaultServerDiscoveryError} defaultServerDiscoveryError={this.state.defaultServerDiscoveryError}
defaultHsUrl={this.getDefaultHsUrl()} defaultHsUrl={this.getDefaultHsUrl()}
defaultIsUrl={this.getDefaultIsUrl()} defaultIsUrl={this.getDefaultIsUrl()}

View File

@ -66,10 +66,6 @@ module.exports = React.createClass({
// different home server without confusing users. // different home server without confusing users.
fallbackHsUrl: PropTypes.string, fallbackHsUrl: PropTypes.string,
// The default server name to use when the user hasn't specified
// one. This is used when displaying the defaultHsUrl in the UI.
defaultServerName: PropTypes.string,
// An error passed along from higher up explaining that something // An error passed along from higher up explaining that something
// went wrong when finding the defaultHsUrl. // went wrong when finding the defaultHsUrl.
defaultServerDiscoveryError: PropTypes.string, defaultServerDiscoveryError: PropTypes.string,
@ -655,7 +651,6 @@ module.exports = React.createClass({
onForgotPasswordClick={this.props.onForgotPasswordClick} onForgotPasswordClick={this.props.onForgotPasswordClick}
loginIncorrect={this.state.loginIncorrect} loginIncorrect={this.state.loginIncorrect}
hsUrl={this.state.enteredHomeserverUrl} hsUrl={this.state.enteredHomeserverUrl}
hsName={this.props.defaultServerName}
disableSubmit={this.state.findingHomeserver} disableSubmit={this.state.findingHomeserver}
/> />
); );

View File

@ -56,10 +56,6 @@ module.exports = React.createClass({
email: PropTypes.string, email: PropTypes.string,
referrer: PropTypes.string, referrer: PropTypes.string,
// The default server name to use when the user hasn't specified
// one. This is used when displaying the defaultHsUrl in the UI.
defaultServerName: PropTypes.string,
// An error passed along from higher up explaining that something // An error passed along from higher up explaining that something
// went wrong when finding the defaultHsUrl. // went wrong when finding the defaultHsUrl.
defaultServerDiscoveryError: PropTypes.string, defaultServerDiscoveryError: PropTypes.string,
@ -473,7 +469,6 @@ module.exports = React.createClass({
onEditServerDetailsClick={onEditServerDetailsClick} onEditServerDetailsClick={onEditServerDetailsClick}
flows={this.state.flows} flows={this.state.flows}
hsUrl={this.state.hsUrl} hsUrl={this.state.hsUrl}
hsName={this.props.defaultServerName}
/>; />;
} }
}, },

View File

@ -41,7 +41,6 @@ class PasswordLogin extends React.Component {
initialPassword: "", initialPassword: "",
loginIncorrect: false, loginIncorrect: false,
hsUrl: "", hsUrl: "",
hsName: null,
disableSubmit: false, disableSubmit: false,
} }
@ -251,15 +250,13 @@ class PasswordLogin extends React.Component {
} }
let yourMatrixAccountText = _t('Your account'); let yourMatrixAccountText = _t('Your account');
if (this.props.hsName) { try {
yourMatrixAccountText = _t('Your %(serverName)s account', {serverName: this.props.hsName}); const parsedHsUrl = new URL(this.props.hsUrl);
} else { yourMatrixAccountText = _t('Your %(serverName)s account', {
try { serverName: parsedHsUrl.hostname,
const parsedHsUrl = new URL(this.props.hsUrl); });
yourMatrixAccountText = _t('Your %(serverName)s account', {serverName: parsedHsUrl.hostname}); } catch (e) {
} catch (e) { // ignore
// ignore
}
} }
let editLink = null; let editLink = null;
@ -341,7 +338,6 @@ PasswordLogin.propTypes = {
onPhoneNumberChanged: PropTypes.func, onPhoneNumberChanged: PropTypes.func,
onPasswordChanged: PropTypes.func, onPasswordChanged: PropTypes.func,
loginIncorrect: PropTypes.bool, loginIncorrect: PropTypes.bool,
hsName: PropTypes.string,
disableSubmit: PropTypes.bool, disableSubmit: PropTypes.bool,
}; };

View File

@ -51,6 +51,7 @@ module.exports = React.createClass({
onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise
onEditServerDetailsClick: PropTypes.func, onEditServerDetailsClick: PropTypes.func,
flows: PropTypes.arrayOf(PropTypes.object).isRequired, flows: PropTypes.arrayOf(PropTypes.object).isRequired,
hsUrl: PropTypes.string,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -258,19 +259,13 @@ module.exports = React.createClass({
const self = this; const self = this;
let yourMatrixAccountText = _t('Create your account'); let yourMatrixAccountText = _t('Create your account');
if (this.props.hsName) { try {
const parsedHsUrl = new URL(this.props.hsUrl);
yourMatrixAccountText = _t('Create your %(serverName)s account', { yourMatrixAccountText = _t('Create your %(serverName)s account', {
serverName: this.props.hsName, serverName: parsedHsUrl.hostname,
}); });
} else { } catch (e) {
try { // ignore
const parsedHsUrl = new URL(this.props.hsUrl);
yourMatrixAccountText = _t('Create your %(serverName)s account', {
serverName: parsedHsUrl.hostname,
});
} catch (e) {
// ignore
}
} }
let editLink = null; let editLink = null;