diff --git a/src/components/views/settings/SetIdServer.js b/src/components/views/settings/SetIdServer.js
index 22b2330f33..398e578e8d 100644
--- a/src/components/views/settings/SetIdServer.js
+++ b/src/components/views/settings/SetIdServer.js
@@ -20,6 +20,7 @@ import {_t} from "../../../languageHandler";
import sdk from '../../../index';
import MatrixClientPeg from "../../../MatrixClientPeg";
import SdkConfig from "../../../SdkConfig";
+import Modal from '../../../Modal';
import dis from "../../../dispatcher";
/**
@@ -149,7 +150,49 @@ export default class SetIdServer extends React.Component {
});
};
+ _onDisconnectClicked = () => {
+ const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
+ Modal.createTrackedDialog('Identity Server Disconnect Warning', '', QuestionDialog, {
+ title: _t("Disconnect Identity Server"),
+ description:
+
+ {_t(
+ "Disconnect from the identity server ?", {},
+ {idserver: sub => {abbreviateUrl(this.state.currentClientIdServer)}},
+ )},
+
,
+ button: _t("Disconnect"),
+ onFinished: (confirmed) => {
+ if (confirmed) {
+ this._disconnectIdServer();
+ }
+ },
+ });
+ };
+
+ _disconnectIdServer = () => {
+ MatrixClientPeg.get().setIdentityServerUrl(null);
+ localStorage.removeItem("mx_is_access_token");
+ localStorage.removeItem("mx_is_url");
+
+ let newFieldVal = '';
+ if (SdkConfig.get()['validated_server_config']['isUrl']) {
+ // Prepopulate the client's default so the user at least has some idea of
+ // a valid value they might enter
+ newFieldVal = abbreviateUrl(SdkConfig.get()['validated_server_config']['isUrl']);
+ }
+
+ this.setState({
+ busy: false,
+ error: null,
+ currentClientIdServer: MatrixClientPeg.get().getIdentityServerUrl(),
+ idServer: newFieldVal,
+ });
+ };
+
render() {
+ const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton');
+ const Field = sdk.getComponent('elements.Field');
const idServerUrl = this.state.currentClientIdServer;
let sectionTitle;
let bodyText;
@@ -170,8 +213,20 @@ export default class SetIdServer extends React.Component {
);
}
- const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
- const Field = sdk.getComponent('elements.Field');
+ let discoSection;
+ if (idServerUrl) {
+ discoSection =
+
{_t(
+ "Disconnecting from your identity server will mean you " +
+ "won't be discoverable by other users and you won't be " +
+ "able to invite others by email or phone.",
+ )}
+
+ {_t("Disconnect")}
+
+
;
+ }
+
return (
);
}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 9639ac0cd9..e5ecc2bf19 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -543,10 +543,14 @@
"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",
+ "Disconnect Identity Server": "Disconnect Identity Server",
+ "Disconnect from the identity server ?": "Disconnect from the identity server ?",
+ "Disconnect": "Disconnect",
"Identity Server (%(server)s)": "Identity Server (%(server)s)",
"You are currently using to discover and be discoverable by existing contacts you know. You can change your identity server below.": "You are currently using to discover and be discoverable by existing contacts you know. You can change your identity server below.",
"Identity Server": "Identity Server",
"You are not currently using an identity server. To discover and be discoverable by existing contacts you know, add one below.": "You are not currently using an identity server. To discover and be discoverable by existing contacts you know, add one below.",
+ "Disconnecting from your identity server will mean you won't be discoverable by other users and you won't be able to invite others by email or phone.": "Disconnecting from your identity server will mean you won't be discoverable by other users and you won't be able to invite others by email or phone.",
"Change": "Change",
"Flair": "Flair",
"Failed to change password. Is your password correct?": "Failed to change password. Is your password correct?",