From 9402e81835641da1a7345c05e3c3eb003b99a190 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 28 Feb 2019 20:34:34 -0700 Subject: [PATCH 1/3] Get confirmation before enabling encryption Fixes https://github.com/vector-im/riot-web/issues/8843 --- .../tabs/room/SecurityRoomSettingsTab.js | 40 +++++++++++++++---- src/i18n/strings/en_EN.json | 2 + 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js index a6eca3bf19..a3d0bac2ba 100644 --- a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js @@ -21,6 +21,8 @@ import MatrixClientPeg from "../../../../../MatrixClientPeg"; import sdk from "../../../../.."; import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch"; import {SettingLevel} from "../../../../../settings/SettingsStore"; +import Modal from "../../../../../Modal"; +import QuestionDialog from "../../../dialogs/QuestionDialog"; export default class SecurityRoomSettingsTab extends React.Component { static propTypes = { @@ -83,14 +85,36 @@ export default class SecurityRoomSettingsTab extends React.Component { }; _onEncryptionChange = (e) => { - const beforeEncrypted = this.state.encrypted; - this.setState({encrypted: true}); - MatrixClientPeg.get().sendStateEvent( - this.props.roomId, "m.room.encryption", - { algorithm: "m.megolm.v1.aes-sha2" }, - ).catch((e) => { - console.error(e); - this.setState({encrypted: beforeEncrypted}); + Modal.createTrackedDialog('Enable encryption', '', QuestionDialog, { + title: _t('Enable encryption?'), + description: _t( + "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted " + + "room cannot be seen by the server, only be the participants of the room. Enabling encryption " + + "may prevent many bots and bridges from working correctly. Learn more about encryption.", + {}, + { + 'a': (sub) => { + return {sub}; + }, + }, + ), + onFinished: (confirm) => { + if (!confirm) { + this.setState({encrypted: false}); + return; + } + + const beforeEncrypted = this.state.encrypted; + this.setState({encrypted: true}); + MatrixClientPeg.get().sendStateEvent( + this.props.roomId, "m.room.encryption", + { algorithm: "m.megolm.v1.aes-sha2" }, + ).catch((e) => { + console.error(e); + this.setState({encrypted: beforeEncrypted}); + }); + }, }); }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 696bd8152c..8ef0d92601 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -612,6 +612,8 @@ "To send events of type , you must be a": "To send events of type , you must be a", "Roles & Permissions": "Roles & Permissions", "Permissions": "Permissions", + "Enable encryption?": "Enable encryption?", + "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only be the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only be the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.", "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "Click here to fix": "Click here to fix", "To link to this room, please add an alias.": "To link to this room, please add an alias.", From 7d207ca2c3e502adb056ef5b0f90512e738593c7 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 28 Feb 2019 20:45:31 -0700 Subject: [PATCH 2/3] speeling --- .../views/settings/tabs/room/SecurityRoomSettingsTab.js | 2 +- src/i18n/strings/en_EN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js index a3d0bac2ba..f4293a60dc 100644 --- a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js @@ -89,7 +89,7 @@ export default class SecurityRoomSettingsTab extends React.Component { title: _t('Enable encryption?'), description: _t( "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted " + - "room cannot be seen by the server, only be the participants of the room. Enabling encryption " + + "room cannot be seen by the server, only by the participants of the room. Enabling encryption " + "may prevent many bots and bridges from working correctly. Learn more about encryption.", {}, { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8ef0d92601..3ed024f4c0 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -613,7 +613,7 @@ "Roles & Permissions": "Roles & Permissions", "Permissions": "Permissions", "Enable encryption?": "Enable encryption?", - "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only be the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only be the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.", + "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.", "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "Click here to fix": "Click here to fix", "To link to this room, please add an alias.": "To link to this room, please add an alias.", From e1cb2ae3a6638c67936737fd8b63aa95dc511328 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 4 Mar 2019 23:14:55 -0700 Subject: [PATCH 3/3] fix i18n --- src/i18n/strings/en_EN.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c6e285f8e2..7469d5f69c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -613,9 +613,9 @@ "Send %(eventType)s events": "Send %(eventType)s events", "Roles & Permissions": "Roles & Permissions", "Permissions": "Permissions", + "Select the roles required to change various parts of the room": "Select the roles required to change various parts of the room", "Enable encryption?": "Enable encryption?", "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.", - "Select the roles required to change various parts of the room": "Select the roles required to change various parts of the room", "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "Click here to fix": "Click here to fix", "To link to this room, please add an alias.": "To link to this room, please add an alias.",