Show warning dialog when changing unreachable IS

If the IS is unreachable, this handles the error by showing a warning
encouraging the user to check after their personal data and resolve the
situation, but still allows them to continue if they want.

Fixes https://github.com/vector-im/riot-web/issues/10909
This commit is contained in:
J. Ryan Stinnett 2019-10-11 15:57:12 +01:00
parent d7631ed9f8
commit e6a81c5733
2 changed files with 48 additions and 8 deletions

View file

@ -249,20 +249,55 @@ export default class SetIdServer extends React.Component {
};
async _showServerChangeWarning({ title, unboundMessage, button }) {
const threepids = await getThreepidsWithBindStatus(MatrixClientPeg.get());
const { currentClientIdServer } = this.state;
let threepids = [];
let currentServerReachable = true;
try {
threepids = await getThreepidsWithBindStatus(MatrixClientPeg.get());
} catch (e) {
currentServerReachable = false;
console.warn(
`Unable to reach identity server at ${currentClientIdServer} to check ` +
`for 3PIDs during IS change flow`,
);
console.warn(e);
}
const boundThreepids = threepids.filter(tp => tp.bound);
let message;
let danger = false;
if (boundThreepids.length) {
const messageElements = {
idserver: sub => <b>{abbreviateUrl(currentClientIdServer)}</b>,
b: sub => <b>{sub}</b>,
};
if (!currentServerReachable) {
message = <div>
<p>{_t(
"You should <b>remove your personal data</b> from identity server " +
"<idserver /> before disconnecting. Unfortunately, identity server " +
"<idserver /> is currently offline or cannot be reached.",
{}, messageElements,
)}</p>
<p>{_t("You should:")}</p>
<ul>
<li>{_t(
"check your browser plugins for anything that might block " +
"the identity server (such as Privacy Badger)",
)}</li>
<li>{_t("contact the administrators of identity server <idserver />", {}, {
idserver: messageElements.idserver,
})}</li>
<li>{_t("wait and try again later")}</li>
</ul>
</div>;
danger = true;
button = _t("Disconnect anyway");
} else if (boundThreepids.length) {
message = <div>
<p>{_t(
"You are still <b>sharing your personal data</b> on the identity " +
"server <idserver />.", {},
{
idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>,
b: sub => <b>{sub}</b>,
},
"server <idserver />.", {}, messageElements,
)}</p>
<p>{_t(
"We recommend that you remove your email addresses and phone numbers " +