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
pull/21833/head
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 }) { 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); const boundThreepids = threepids.filter(tp => tp.bound);
let message; let message;
let danger = false; 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> message = <div>
<p>{_t( <p>{_t(
"You are still <b>sharing your personal data</b> on the identity " + "You are still <b>sharing your personal data</b> on the identity " +
"server <idserver />.", {}, "server <idserver />.", {}, messageElements,
{
idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>,
b: sub => <b>{sub}</b>,
},
)}</p> )}</p>
<p>{_t( <p>{_t(
"We recommend that you remove your email addresses and phone numbers " + "We recommend that you remove your email addresses and phone numbers " +

View File

@ -568,9 +568,14 @@
"Disconnect identity server": "Disconnect identity server", "Disconnect identity server": "Disconnect identity server",
"Disconnect from the identity server <idserver />?": "Disconnect from the identity server <idserver />?", "Disconnect from the identity server <idserver />?": "Disconnect from the identity server <idserver />?",
"Disconnect": "Disconnect", "Disconnect": "Disconnect",
"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.": "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.",
"You should:": "You should:",
"check your browser plugins for anything that might block the identity server (such as Privacy Badger)": "check your browser plugins for anything that might block the identity server (such as Privacy Badger)",
"contact the administrators of identity server <idserver />": "contact the administrators of identity server <idserver />",
"wait and try again later": "wait and try again later",
"Disconnect anyway": "Disconnect anyway",
"You are still <b>sharing your personal data</b> on the identity server <idserver />.": "You are still <b>sharing your personal data</b> on the identity server <idserver />.", "You are still <b>sharing your personal data</b> on the identity server <idserver />.": "You are still <b>sharing your personal data</b> on the identity server <idserver />.",
"We recommend that you remove your email addresses and phone numbers from the identity server before disconnecting.": "We recommend that you remove your email addresses and phone numbers from the identity server before disconnecting.", "We recommend that you remove your email addresses and phone numbers from the identity server before disconnecting.": "We recommend that you remove your email addresses and phone numbers from the identity server before disconnecting.",
"Disconnect anyway": "Disconnect anyway",
"Go back": "Go back", "Go back": "Go back",
"Identity Server (%(server)s)": "Identity Server (%(server)s)", "Identity Server (%(server)s)": "Identity Server (%(server)s)",
"You are currently using <server></server> to discover and be discoverable by existing contacts you know. You can change your identity server below.": "You are currently using <server></server> to discover and be discoverable by existing contacts you know. You can change your identity server below.", "You are currently using <server></server> to discover and be discoverable by existing contacts you know. You can change your identity server below.": "You are currently using <server></server> to discover and be discoverable by existing contacts you know. You can change your identity server below.",