Treat 404 errors on IS as having no terms

Fixes https://github.com/vector-im/riot-web/issues/10634
pull/21833/head
Travis Ralston 2019-08-23 11:58:04 -06:00
parent 47ee299e70
commit c44ae2df4d
1 changed files with 27 additions and 19 deletions

View File

@ -153,6 +153,30 @@ 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) {
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.");
}
}
this.setState({
busy: false,
checking: false,
error: errStr,
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
idServer: this.state.idServer,
});
};
_showNoTermsWarning(fullUrl) {
const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
title: _t("Identity server has no terms of service"),
@ -172,22 +196,6 @@ export default class SetIdServer extends React.Component {
this._saveIdServer(fullUrl);
},
});
return;
}
this._saveIdServer(fullUrl);
} catch (e) {
console.error(e);
errStr = _t("Terms of service not accepted or the identity server is invalid.");
}
}
this.setState({
busy: false,
checking: false,
error: errStr,
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
idServer: this.state.idServer,
});
};
_onDisconnectClicked = async () => {