mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Merge pull request #3394 from matrix-org/jryans/bound-3pids-warning
Add bound 3PID warning when changing IS as well
This commit is contained in:
commit
a03b224ff7
@ -130,15 +130,21 @@ export default class SetIdServer extends React.Component {
|
||||
MatrixClientPeg.get().setAccountData("m.identity_server", {
|
||||
base_url: fullUrl,
|
||||
});
|
||||
this.setState({idServer: '', busy: false, error: null});
|
||||
this.setState({
|
||||
busy: false,
|
||||
error: null,
|
||||
currentClientIdServer: fullUrl,
|
||||
idServer: '',
|
||||
});
|
||||
};
|
||||
|
||||
_checkIdServer = async (e) => {
|
||||
e.preventDefault();
|
||||
const { idServer, currentClientIdServer } = this.state;
|
||||
|
||||
this.setState({busy: true, checking: true, error: null});
|
||||
|
||||
const fullUrl = unabbreviateUrl(this.state.idServer);
|
||||
const fullUrl = unabbreviateUrl(idServer);
|
||||
|
||||
let errStr = await checkIdentityServerUrl(fullUrl);
|
||||
if (!errStr) {
|
||||
@ -150,20 +156,49 @@ export default class SetIdServer extends React.Component {
|
||||
const authClient = new IdentityAuthClient(fullUrl);
|
||||
await authClient.getAccessToken();
|
||||
|
||||
// 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;
|
||||
}
|
||||
let save = true;
|
||||
|
||||
this._saveIdServer(fullUrl);
|
||||
// Double check that the identity server even has terms of service.
|
||||
let terms;
|
||||
try {
|
||||
terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
if (e.cors === "rejected" || e.httpStatus === 404) {
|
||||
this._showNoTermsWarning(fullUrl);
|
||||
return;
|
||||
terms = null;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!terms || !terms["policies"] || Object.keys(terms["policies"]).length <= 0) {
|
||||
const [confirmed] = await this._showNoTermsWarning(fullUrl);
|
||||
save = confirmed;
|
||||
}
|
||||
|
||||
// Show a general warning, possibly with details about any bound
|
||||
// 3PIDs that would be left behind.
|
||||
if (save && currentClientIdServer && fullUrl !== currentClientIdServer) {
|
||||
const [confirmed] = await this._showServerChangeWarning({
|
||||
title: _t("Change identity server"),
|
||||
unboundMessage: _t(
|
||||
"Disconnect from the identity server <current /> and " +
|
||||
"connect to <new /> instead?", {},
|
||||
{
|
||||
current: sub => <b>{abbreviateUrl(currentClientIdServer)}</b>,
|
||||
new: sub => <b>{abbreviateUrl(idServer)}</b>,
|
||||
},
|
||||
),
|
||||
button: _t("Continue"),
|
||||
});
|
||||
save = confirmed;
|
||||
}
|
||||
|
||||
if (save) {
|
||||
this._saveIdServer(fullUrl);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
errStr = _t("Terms of service not accepted or the identity server is invalid.");
|
||||
}
|
||||
}
|
||||
@ -172,13 +207,12 @@ export default class SetIdServer extends React.Component {
|
||||
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, {
|
||||
const { finished } = Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
|
||||
title: _t("Identity server has no terms of service"),
|
||||
description: (
|
||||
<div>
|
||||
@ -191,54 +225,67 @@ export default class SetIdServer extends React.Component {
|
||||
</div>
|
||||
),
|
||||
button: _t("Continue"),
|
||||
onFinished: async (confirmed) => {
|
||||
if (!confirmed) return;
|
||||
this._saveIdServer(fullUrl);
|
||||
},
|
||||
});
|
||||
return finished;
|
||||
}
|
||||
|
||||
_onDisconnectClicked = async () => {
|
||||
this.setState({disconnectBusy: true});
|
||||
try {
|
||||
const threepids = await getThreepidBindStatus(MatrixClientPeg.get());
|
||||
|
||||
const boundThreepids = threepids.filter(tp => tp.bound);
|
||||
let message;
|
||||
if (boundThreepids.length) {
|
||||
message = _t(
|
||||
"You are currently sharing email addresses or phone numbers on the identity " +
|
||||
"server <idserver />. You will need to reconnect to <idserver2 /> to stop " +
|
||||
"sharing them.", {},
|
||||
{
|
||||
idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>,
|
||||
// XXX: https://github.com/vector-im/riot-web/issues/9086
|
||||
idserver2: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
message = _t(
|
||||
const [confirmed] = await this._showServerChangeWarning({
|
||||
title: _t("Disconnect identity server"),
|
||||
unboundMessage: _t(
|
||||
"Disconnect from the identity server <idserver />?", {},
|
||||
{idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>},
|
||||
);
|
||||
}
|
||||
|
||||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||
Modal.createTrackedDialog('Identity Server Disconnect Warning', '', QuestionDialog, {
|
||||
title: _t("Disconnect Identity Server"),
|
||||
description: message,
|
||||
),
|
||||
button: _t("Disconnect"),
|
||||
onFinished: (confirmed) => {
|
||||
});
|
||||
if (confirmed) {
|
||||
this._disconnectIdServer();
|
||||
}
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
this.setState({disconnectBusy: false});
|
||||
}
|
||||
};
|
||||
|
||||
async _showServerChangeWarning({ title, unboundMessage, button }) {
|
||||
const threepids = await getThreepidBindStatus(MatrixClientPeg.get());
|
||||
|
||||
const boundThreepids = threepids.filter(tp => tp.bound);
|
||||
let message;
|
||||
let danger = false;
|
||||
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>,
|
||||
},
|
||||
)}</p>
|
||||
<p>{_t(
|
||||
"We recommend that you remove your email addresses and phone numbers " +
|
||||
"from the identity server before disconnecting.",
|
||||
)}</p>
|
||||
</div>;
|
||||
danger = true;
|
||||
button = _t("Disconnect anyway");
|
||||
} else {
|
||||
message = unboundMessage;
|
||||
}
|
||||
|
||||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||
const { finished } = Modal.createTrackedDialog('Identity Server Bound Warning', '', QuestionDialog, {
|
||||
title,
|
||||
description: message,
|
||||
button,
|
||||
cancelButton: _t("Go back"),
|
||||
danger,
|
||||
});
|
||||
return finished;
|
||||
}
|
||||
|
||||
_disconnectIdServer = () => {
|
||||
// Account data change will update localstorage, client, etc through dispatcher
|
||||
MatrixClientPeg.get().setAccountData("m.identity_server", {
|
||||
|
@ -554,14 +554,19 @@
|
||||
"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",
|
||||
"Change identity server": "Change identity server",
|
||||
"Disconnect from the identity server <current /> and connect to <new /> instead?": "Disconnect from the identity server <current /> and connect to <new /> instead?",
|
||||
"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.",
|
||||
"You are currently sharing email addresses or phone numbers on the identity server <idserver />. You will need to reconnect to <idserver2 /> to stop sharing them.": "You are currently sharing email addresses or phone numbers on the identity server <idserver />. You will need to reconnect to <idserver2 /> to stop sharing them.",
|
||||
"Disconnect identity server": "Disconnect identity server",
|
||||
"Disconnect from the identity server <idserver />?": "Disconnect from the identity server <idserver />?",
|
||||
"Disconnect Identity Server": "Disconnect Identity Server",
|
||||
"Disconnect": "Disconnect",
|
||||
"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.",
|
||||
"Disconnect anyway": "Disconnect anyway",
|
||||
"Go back": "Go back",
|
||||
"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.",
|
||||
"If you don't want to use <server /> to discover and be discoverable by existing contacts you know, enter another identity server below.": "If you don't want to use <server /> to discover and be discoverable by existing contacts you know, enter another identity server below.",
|
||||
@ -1290,7 +1295,6 @@
|
||||
"If you run into any bugs or have feedback you'd like to share, please let us know on GitHub.": "If you run into any bugs or have feedback you'd like to share, please let us know on GitHub.",
|
||||
"To help avoid duplicate issues, please <existingIssuesLink>view existing issues</existingIssuesLink> first (and add a +1) or <newIssueLink>create a new issue</newIssueLink> if you can't find it.": "To help avoid duplicate issues, please <existingIssuesLink>view existing issues</existingIssuesLink> first (and add a +1) or <newIssueLink>create a new issue</newIssueLink> if you can't find it.",
|
||||
"Report bugs & give feedback": "Report bugs & give feedback",
|
||||
"Go back": "Go back",
|
||||
"Room Settings - %(roomName)s": "Room Settings - %(roomName)s",
|
||||
"Failed to upgrade room": "Failed to upgrade room",
|
||||
"The room upgrade could not be completed": "The room upgrade could not be completed",
|
||||
|
Loading…
Reference in New Issue
Block a user