Merge pull request #2728 from matrix-org/travis/encryption-warning

Get confirmation before enabling encryption
This commit is contained in:
Travis Ralston 2019-03-05 10:15:32 -07:00 committed by GitHub
commit 6eaaa8b687
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 8 deletions

View file

@ -21,6 +21,8 @@ import MatrixClientPeg from "../../../../../MatrixClientPeg";
import sdk from "../../../../.."; import sdk from "../../../../..";
import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch"; import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch";
import {SettingLevel} from "../../../../../settings/SettingsStore"; import {SettingLevel} from "../../../../../settings/SettingsStore";
import Modal from "../../../../../Modal";
import QuestionDialog from "../../../dialogs/QuestionDialog";
export default class SecurityRoomSettingsTab extends React.Component { export default class SecurityRoomSettingsTab extends React.Component {
static propTypes = { static propTypes = {
@ -83,14 +85,36 @@ export default class SecurityRoomSettingsTab extends React.Component {
}; };
_onEncryptionChange = (e) => { _onEncryptionChange = (e) => {
const beforeEncrypted = this.state.encrypted; Modal.createTrackedDialog('Enable encryption', '', QuestionDialog, {
this.setState({encrypted: true}); title: _t('Enable encryption?'),
MatrixClientPeg.get().sendStateEvent( description: _t(
this.props.roomId, "m.room.encryption", "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted " +
{ algorithm: "m.megolm.v1.aes-sha2" }, "room cannot be seen by the server, only by the participants of the room. Enabling encryption " +
).catch((e) => { "may prevent many bots and bridges from working correctly. <a>Learn more about encryption.</a>",
console.error(e); {},
this.setState({encrypted: beforeEncrypted}); {
'a': (sub) => {
return <a rel='noopener' target='_blank'
href='https://about.riot.im/help#end-to-end-encryption'>{sub}</a>;
},
},
),
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});
});
},
}); });
}; };

View file

@ -614,6 +614,8 @@
"Roles & Permissions": "Roles & Permissions", "Roles & Permissions": "Roles & Permissions",
"Permissions": "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", "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. <a>Learn more about encryption.</a>": "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. <a>Learn more about encryption.</a>",
"Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "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", "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.", "To link to this room, please add an alias.": "To link to this room, please add an alias.",