mirror of https://github.com/vector-im/riot-web
Add bound 3PID warning when changing IS as well
This extends the bound 3PID warning from the disconnect button to also appear when changing the IS as well. At the moment, the text is a bit terse, but will be improved separately. Fixes https://github.com/vector-im/riot-web/issues/10749pull/21833/head
parent
46ee52a406
commit
d5552e4a17
|
@ -137,7 +137,12 @@ export default class SetIdServer extends React.Component {
|
||||||
MatrixClientPeg.get().setAccountData("m.identity_server", {
|
MatrixClientPeg.get().setAccountData("m.identity_server", {
|
||||||
base_url: fullUrl,
|
base_url: fullUrl,
|
||||||
});
|
});
|
||||||
this.setState({idServer: '', busy: false, error: null});
|
this.setState({
|
||||||
|
busy: false,
|
||||||
|
error: null,
|
||||||
|
currentClientIdServer: fullUrl,
|
||||||
|
idServer: '',
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_checkIdServer = async (e) => {
|
_checkIdServer = async (e) => {
|
||||||
|
@ -157,14 +162,34 @@ export default class SetIdServer extends React.Component {
|
||||||
const authClient = new IdentityAuthClient(fullUrl);
|
const authClient = new IdentityAuthClient(fullUrl);
|
||||||
await authClient.getAccessToken();
|
await authClient.getAccessToken();
|
||||||
|
|
||||||
|
let save = true;
|
||||||
|
|
||||||
// Double check that the identity server even has terms of service.
|
// Double check that the identity server even has terms of service.
|
||||||
const terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl);
|
const terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl);
|
||||||
if (!terms || !terms["policies"] || Object.keys(terms["policies"]).length <= 0) {
|
if (!terms || !terms["policies"] || Object.keys(terms["policies"]).length <= 0) {
|
||||||
this._showNoTermsWarning(fullUrl);
|
save &= await this._showNoTermsWarning(fullUrl);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show a general warning, possibly with details about any bound
|
||||||
|
// 3PIDs that would be left behind.
|
||||||
|
if (this.state.currentClientIdServer) {
|
||||||
|
save &= 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(this.state.currentClientIdServer)}</b>,
|
||||||
|
new: sub => <b>{abbreviateUrl(this.state.idServer)}</b>,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
button: _t("Continue"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (save) {
|
||||||
this._saveIdServer(fullUrl);
|
this._saveIdServer(fullUrl);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
if (e.cors === "rejected" || e.httpStatus === 404) {
|
if (e.cors === "rejected" || e.httpStatus === 404) {
|
||||||
|
@ -179,12 +204,12 @@ export default class SetIdServer extends React.Component {
|
||||||
checking: false,
|
checking: false,
|
||||||
error: errStr,
|
error: errStr,
|
||||||
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
|
||||||
idServer: this.state.idServer,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_showNoTermsWarning(fullUrl) {
|
_showNoTermsWarning(fullUrl) {
|
||||||
const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
|
||||||
|
return new Promise(resolve => {
|
||||||
Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
|
Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
|
||||||
title: _t("Identity server has no terms of service"),
|
title: _t("Identity server has no terms of service"),
|
||||||
description: (
|
description: (
|
||||||
|
@ -198,16 +223,31 @@ export default class SetIdServer extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
button: _t("Continue"),
|
button: _t("Continue"),
|
||||||
onFinished: async (confirmed) => {
|
onFinished: resolve,
|
||||||
if (!confirmed) return;
|
});
|
||||||
this._saveIdServer(fullUrl);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDisconnectClicked = async () => {
|
_onDisconnectClicked = async () => {
|
||||||
this.setState({disconnectBusy: true});
|
this.setState({disconnectBusy: true});
|
||||||
try {
|
try {
|
||||||
|
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>},
|
||||||
|
),
|
||||||
|
button: _t("Disconnect"),
|
||||||
|
});
|
||||||
|
if (confirmed) {
|
||||||
|
this._disconnectIdServer();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.setState({disconnectBusy: false});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async _showServerChangeWarning({ title, unboundMessage, button }) {
|
||||||
const threepids = await getThreepidBindStatus(MatrixClientPeg.get());
|
const threepids = await getThreepidBindStatus(MatrixClientPeg.get());
|
||||||
|
|
||||||
const boundThreepids = threepids.filter(tp => tp.bound);
|
const boundThreepids = threepids.filter(tp => tp.bound);
|
||||||
|
@ -224,27 +264,19 @@ export default class SetIdServer extends React.Component {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
message = _t(
|
message = unboundMessage;
|
||||||
"Disconnect from the identity server <idserver />?", {},
|
|
||||||
{idserver: sub => <b>{abbreviateUrl(this.state.currentClientIdServer)}</b>},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
Modal.createTrackedDialog('Identity Server Disconnect Warning', '', QuestionDialog, {
|
return new Promise(resolve => {
|
||||||
title: _t("Disconnect Identity Server"),
|
Modal.createTrackedDialog('Identity Server Bound Warning', '', QuestionDialog, {
|
||||||
|
title,
|
||||||
description: message,
|
description: message,
|
||||||
button: _t("Disconnect"),
|
button,
|
||||||
onFinished: (confirmed) => {
|
onFinished: resolve,
|
||||||
if (confirmed) {
|
});
|
||||||
this._disconnectIdServer();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
} finally {
|
|
||||||
this.setState({disconnectBusy: false});
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
_disconnectIdServer = () => {
|
_disconnectIdServer = () => {
|
||||||
// Account data change will update localstorage, client, etc through dispatcher
|
// Account data change will update localstorage, client, etc through dispatcher
|
||||||
|
|
|
@ -554,14 +554,16 @@
|
||||||
"Not a valid Identity Server (status code %(code)s)": "Not a valid Identity Server (status code %(code)s)",
|
"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",
|
"Could not connect to Identity Server": "Could not connect to Identity Server",
|
||||||
"Checking server": "Checking 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.",
|
"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",
|
"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.",
|
"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.",
|
"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 from the identity server <idserver />?": "Disconnect from the identity server <idserver />?",
|
||||||
"Disconnect Identity Server": "Disconnect Identity Server",
|
|
||||||
"Disconnect": "Disconnect",
|
"Disconnect": "Disconnect",
|
||||||
|
"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.",
|
||||||
"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.",
|
||||||
"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.",
|
"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.",
|
||||||
|
|
Loading…
Reference in New Issue