From 650185e5785753d08f1a122480462b4e4148bf63 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 5 Apr 2019 10:35:11 -0600 Subject: [PATCH 1/2] Remove 'try the app' link from login Fixes https://github.com/vector-im/riot-web/issues/8384 This will be re-addressed in https://github.com/vector-im/riot-web/issues/9388 or similar. Because the implementation is undefined, the dead code is being removed instead of just left dead. --- src/components/structures/MatrixChat.js | 1 - src/components/structures/auth/Login.js | 42 ------------------------- src/i18n/strings/en_EN.json | 2 -- 3 files changed, 45 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index f64d546bbb..19ac145c08 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -2032,7 +2032,6 @@ export default React.createClass({ fallbackHsUrl={this.getFallbackHsUrl()} defaultDeviceDisplayName={this.props.defaultDeviceDisplayName} onForgotPasswordClick={this.onForgotPasswordClick} - enableGuest={this.props.enableGuest} onServerConfigChange={this.onServerConfigChange} /> ); diff --git a/src/components/structures/auth/Login.js b/src/components/structures/auth/Login.js index 4e3048483b..61b55b49d6 100644 --- a/src/components/structures/auth/Login.js +++ b/src/components/structures/auth/Login.js @@ -54,8 +54,6 @@ module.exports = React.createClass({ propTypes: { onLoggedIn: PropTypes.func.isRequired, - enableGuest: PropTypes.bool, - // The default server name to use when the user hasn't specified // one. If set, `defaultHsUrl` and `defaultHsUrl` were derived for this // via `.well-known` discovery. The server name is used instead of the @@ -225,37 +223,6 @@ module.exports = React.createClass({ }).done(); }, - _onLoginAsGuestClick: function(ev) { - ev.preventDefault(); - ev.stopPropagation(); - - const self = this; - self.setState({ - busy: true, - errorText: null, - loginIncorrect: false, - }); - - this._loginLogic.loginAsGuest().then(function(data) { - self.props.onLoggedIn(data); - }, function(error) { - let errorText; - if (error.httpStatus === 403) { - errorText = _t("Guest access is disabled on this homeserver."); - } else { - errorText = self._errorTextFromError(error); - } - self.setState({ - errorText: errorText, - loginIncorrect: false, - }); - }).finally(function() { - self.setState({ - busy: false, - }); - }).done(); - }, - onUsernameChanged: function(username) { this.setState({ username: username }); }, @@ -627,14 +594,6 @@ module.exports = React.createClass({ const errorText = this.props.defaultServerDiscoveryError || this.state.discoveryError || this.state.errorText; - let loginAsGuestJsx; - if (this.props.enableGuest) { - loginAsGuestJsx = - - { _t('Try the app first') } - ; - } - let errorTextSection; if (errorText) { errorTextSection = ( @@ -658,7 +617,6 @@ module.exports = React.createClass({ { _t('Create account') } - { loginAsGuestJsx } ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 477ac1df29..e4dbaa593c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1478,7 +1478,6 @@ "Please contact your service administrator to continue using this service.": "Please contact your service administrator to continue using this service.", "Incorrect username and/or password.": "Incorrect username and/or password.", "Please note you are logging into the %(hs)s server, not matrix.org.": "Please note you are logging into the %(hs)s server, not matrix.org.", - "Guest access is disabled on this homeserver.": "Guest access is disabled on this homeserver.", "Failed to perform homeserver discovery": "Failed to perform homeserver discovery", "The phone number entered looks invalid": "The phone number entered looks invalid", "Unknown failure discovering homeserver": "Unknown failure discovering homeserver", @@ -1487,7 +1486,6 @@ "Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or enable unsafe scripts.": "Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or enable unsafe scripts.", "Can't connect to homeserver - please check your connectivity, ensure your homeserver's SSL certificate is trusted, and that a browser extension is not blocking requests.": "Can't connect to homeserver - please check your connectivity, ensure your homeserver's SSL certificate is trusted, and that a browser extension is not blocking requests.", "Sign in with single sign-on": "Sign in with single sign-on", - "Try the app first": "Try the app first", "Create account": "Create account", "Failed to fetch avatar URL": "Failed to fetch avatar URL", "Set a display name:": "Set a display name:", From 0e7688da98fd4c348662fcaec601e034d3a28475 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 5 Apr 2019 11:00:25 -0600 Subject: [PATCH 2/2] Remove dead Login.loginAsGuest() --- src/Lifecycle.js | 3 --- src/Login.js | 20 -------------------- 2 files changed, 23 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index f65dffa006..527394da4d 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -203,9 +203,6 @@ export function handleInvalidStoreError(e) { function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) { console.log(`Doing guest login on ${hsUrl}`); - // TODO: we should probably de-duplicate this and Login.loginAsGuest. - // Not really sure where the right home for it is. - // create a temporary MatrixClient to do the login const client = Matrix.createClient({ baseUrl: hsUrl, diff --git a/src/Login.js b/src/Login.js index 893ec42097..c31a9308a8 100644 --- a/src/Login.js +++ b/src/Login.js @@ -81,26 +81,6 @@ export default class Login { return flowStep ? flowStep.type : null; } - loginAsGuest() { - const client = this._createTemporaryClient(); - return client.registerGuest({ - body: { - initial_device_display_name: this._defaultDeviceDisplayName, - }, - }).then((creds) => { - return { - userId: creds.user_id, - deviceId: creds.device_id, - accessToken: creds.access_token, - homeserverUrl: this._hsUrl, - identityServerUrl: this._isUrl, - guest: true, - }; - }, (error) => { - throw error; - }); - } - loginViaPassword(username, phoneCountry, phoneNumber, pass) { const self = this;