From c44ae2df4d47b6fb5787cdc50ca01dbf7e12aa1d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 23 Aug 2019 11:58:04 -0600 Subject: [PATCH 1/3] Treat 404 errors on IS as having no terms Fixes https://github.com/vector-im/riot-web/issues/10634 --- src/components/views/settings/SetIdServer.js | 46 ++++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index e7aa22527d..ddd246d928 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -153,31 +153,17 @@ export default class SetIdServer extends React.Component { // Double check that the identity server even has terms of service. const terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl); if (!terms || !terms["policies"] || Object.keys(terms["policies"]).length <= 0) { - const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog"); - Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, { - title: _t("Identity server has no terms of service"), - description: ( -
- - {_t("The identity server you have chosen does not have any terms of service.")} - - -  {_t("Only continue if you trust the owner of the server.")} - -
- ), - button: _t("Continue"), - onFinished: async (confirmed) => { - if (!confirmed) return; - this._saveIdServer(fullUrl); - }, - }); + this._showNoTermsWarning(fullUrl); return; } this._saveIdServer(fullUrl); } catch (e) { console.error(e); + if (e.cors === "rejected" || e.httpStatus === 404) { + this._showNoTermsWarning(fullUrl); + return; + } errStr = _t("Terms of service not accepted or the identity server is invalid."); } } @@ -190,6 +176,28 @@ export default class SetIdServer extends React.Component { }); }; + _showNoTermsWarning(fullUrl) { + const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog"); + Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, { + title: _t("Identity server has no terms of service"), + description: ( +
+ + {_t("The identity server you have chosen does not have any terms of service.")} + + +  {_t("Only continue if you trust the owner of the server.")} + +
+ ), + button: _t("Continue"), + onFinished: async (confirmed) => { + if (!confirmed) return; + this._saveIdServer(fullUrl); + }, + }); + }; + _onDisconnectClicked = async () => { this.setState({disconnectBusy: true}); try { From e1552b61fcece1c776f8ce0bc2e96bca1b2b9a3d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 23 Aug 2019 12:01:13 -0600 Subject: [PATCH 2/3] fix i18n --- src/i18n/strings/en_EN.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 83a9602a51..a0c98a0335 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -549,10 +549,10 @@ "Not a valid Identity Server (status code %(code)s)": "Not a valid Identity Server (status code %(code)s)", "Could not connect to Identity Server": "Could not connect to Identity Server", "Checking server": "Checking server", + "Terms of service not accepted or the identity server is invalid.": "Terms of service not accepted or the identity server is invalid.", "Identity server has no terms of service": "Identity server has no terms of service", "The identity server you have chosen does not have any terms of service.": "The identity server you have chosen does not have any terms of service.", "Only continue if you trust the owner of the server.": "Only continue if you trust the owner of the server.", - "Terms of service not accepted or the identity server is invalid.": "Terms of service not accepted or the identity server is invalid.", "You are currently sharing email addresses or phone numbers on the identity server . You will need to reconnect to to stop sharing them.": "You are currently sharing email addresses or phone numbers on the identity server . You will need to reconnect to to stop sharing them.", "Disconnect from the identity server ?": "Disconnect from the identity server ?", "Disconnect Identity Server": "Disconnect Identity Server", From e8b0c411578d84363b105e7f76e7e4e9b0be7237 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 23 Aug 2019 12:01:47 -0600 Subject: [PATCH 3/3] minus ; --- src/components/views/settings/SetIdServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js index ddd246d928..ba405a5652 100644 --- a/src/components/views/settings/SetIdServer.js +++ b/src/components/views/settings/SetIdServer.js @@ -196,7 +196,7 @@ export default class SetIdServer extends React.Component { this._saveIdServer(fullUrl); }, }); - }; + } _onDisconnectClicked = async () => { this.setState({disconnectBusy: true});