From e016cbeffff7c2a30e9b6169372c726f6eb7e8b3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 31 Jan 2020 17:03:10 +0100 Subject: [PATCH 1/4] support header image in QuestionDialog --- src/components/views/dialogs/QuestionDialog.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/dialogs/QuestionDialog.js b/src/components/views/dialogs/QuestionDialog.js index b165bf79e2..3eec497b44 100644 --- a/src/components/views/dialogs/QuestionDialog.js +++ b/src/components/views/dialogs/QuestionDialog.js @@ -31,6 +31,7 @@ export default createReactClass({ danger: PropTypes.bool, focus: PropTypes.bool, onFinished: PropTypes.func.isRequired, + headerImage: PropTypes.string, }, getDefaultProps: function() { @@ -63,6 +64,7 @@ export default createReactClass({
From 5c89b41177b832e1d7e7bed28d404c8f00b6bec8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 31 Jan 2020 17:03:36 +0100 Subject: [PATCH 2/4] make device verification go over right panel (after showing dialog) dialog should be more or less as in the design --- src/components/views/right_panel/UserInfo.js | 68 ++++++++++++++++++-- src/i18n/strings/en_EN.json | 6 +- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/components/views/right_panel/UserInfo.js b/src/components/views/right_panel/UserInfo.js index cd8952fd72..fc1f5bfcc9 100644 --- a/src/components/views/right_panel/UserInfo.js +++ b/src/components/views/right_panel/UserInfo.js @@ -42,6 +42,8 @@ import {textualPowerLevel} from '../../../Roles'; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import {RIGHT_PANEL_PHASES} from "../../../stores/RightPanelStorePhases"; import EncryptionPanel from "./EncryptionPanel"; +import {verificationMethods} from 'matrix-js-sdk/src/crypto'; +import {SCAN_QR_CODE_METHOD, SHOW_QR_CODE_METHOD} from "matrix-js-sdk/src/crypto/verification/QRCode"; const _disambiguateDevices = (devices) => { const names = Object.create(null); @@ -135,12 +137,66 @@ function useIsEncrypted(cli, room) { return isEncrypted; } -function verifyDevice(userId, device) { - const DeviceVerifyDialog = sdk.getComponent('views.dialogs.DeviceVerifyDialog'); - Modal.createTrackedDialog('Device Verify Dialog', '', DeviceVerifyDialog, { - userId: userId, - device: device, - }, null, /* priority = */ false, /* static = */ true); +async function verifyDevice(userId, device) { + const cli = MatrixClientPeg.get(); + const member = cli.getUser(userId); + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + Modal.createTrackedDialog("Verification failed", "insecure", QuestionDialog, { + headerImage: require("../../../../res/img/e2e/warning.svg"), + title: _t("Not Trusted"), + description:
+

{_t("%(name)s (%(userId)s) signed in to a new session without verifying it:", {name: member.displayName, userId})}

+

{device.getDisplayName()} ({device.deviceId})

+

{_t("Ask this user to verify their session, or manually verify it below.")}

+
, + onFinished: async (doneClicked) => { + const manuallyVerifyClicked = !doneClicked; + if (!manuallyVerifyClicked) { + return; + } + const cli = MatrixClientPeg.get(); + const verificationRequest = await cli.requestVerification( + userId, + [ + verificationMethods.SAS, + SHOW_QR_CODE_METHOD, + SCAN_QR_CODE_METHOD, + verificationMethods.RECIPROCATE_QR_CODE, + ], + [device.deviceId], + ); + dis.dispatch({ + action: "set_right_panel_phase", + phase: RIGHT_PANEL_PHASES.EncryptionPanel, + refireParams: {member, verificationRequest}, + }); + }, + primaryButton: _t("Done"), + cancelButton: _t("Manually Verify"), + }); + + // const cli = MatrixClientPeg.get(); + // const verificationRequest = await cli.requestVerification( + // userId, + // [ + // verificationMethods.SAS, + // SHOW_QR_CODE_METHOD, + // SCAN_QR_CODE_METHOD, + // verificationMethods.RECIPROCATE_QR_CODE, + // ], + // [device.deviceId], + // ); + // dis.dispatch({ + // action: "set_right_panel_phase", + // phase: RIGHT_PANEL_PHASES.EncryptionPanel, + // refireParams: {member, verificationRequest}, + // }); + + // const DeviceVerifyDialog = sdk.getComponent('views.dialogs.DeviceVerifyDialog'); + // Modal.createTrackedDialog('Device Verify Dialog', '', DeviceVerifyDialog, { + // userId: userId, + // device: device, + // }, null, /* priority = */ false, /* static = */ true); } function verifyUser(user) { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 83c15fc385..78a56bbffc 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1166,6 +1166,11 @@ "Yours, or the other users’ session": "Yours, or the other users’ session", "Members": "Members", "Files": "Files", + "Not Trusted": "Not Trusted", + "%(name)s (%(userId)s) signed in to a new session without verifying it:": "%(name)s (%(userId)s) signed in to a new session without verifying it:", + "Ask this user to verify their session, or manually verify it below.": "Ask this user to verify their session, or manually verify it below.", + "Done": "Done", + "Manually Verify": "Manually Verify", "Trusted": "Trusted", "Not trusted": "Not trusted", "%(count)s verified sessions|other": "%(count)s verified sessions", @@ -1928,7 +1933,6 @@ "Session verified": "Session verified", "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.": "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.", "Your new session is now verified. Other users will see it as trusted.": "Your new session is now verified. Other users will see it as trusted.", - "Done": "Done", "Without completing security on this session, it won’t have access to encrypted messages.": "Without completing security on this session, it won’t have access to encrypted messages.", "Go Back": "Go Back", "Failed to send email": "Failed to send email", From 4b8382b5c45f602e88297120e6838a1754140d89 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 10 Feb 2020 17:07:02 +0100 Subject: [PATCH 3/4] remove dead code --- src/components/views/right_panel/UserInfo.js | 23 -------------------- 1 file changed, 23 deletions(-) diff --git a/src/components/views/right_panel/UserInfo.js b/src/components/views/right_panel/UserInfo.js index fc1f5bfcc9..9e0682e380 100644 --- a/src/components/views/right_panel/UserInfo.js +++ b/src/components/views/right_panel/UserInfo.js @@ -174,29 +174,6 @@ async function verifyDevice(userId, device) { primaryButton: _t("Done"), cancelButton: _t("Manually Verify"), }); - - // const cli = MatrixClientPeg.get(); - // const verificationRequest = await cli.requestVerification( - // userId, - // [ - // verificationMethods.SAS, - // SHOW_QR_CODE_METHOD, - // SCAN_QR_CODE_METHOD, - // verificationMethods.RECIPROCATE_QR_CODE, - // ], - // [device.deviceId], - // ); - // dis.dispatch({ - // action: "set_right_panel_phase", - // phase: RIGHT_PANEL_PHASES.EncryptionPanel, - // refireParams: {member, verificationRequest}, - // }); - - // const DeviceVerifyDialog = sdk.getComponent('views.dialogs.DeviceVerifyDialog'); - // Modal.createTrackedDialog('Device Verify Dialog', '', DeviceVerifyDialog, { - // userId: userId, - // device: device, - // }, null, /* priority = */ false, /* static = */ true); } function verifyUser(user) { From 5267dbf44aa3a1aa88bb610ac3f2831cd3231f1a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 11 Feb 2020 15:21:01 +0000 Subject: [PATCH 4/4] Update src/components/views/right_panel/UserInfo.js Co-Authored-By: J. Ryan Stinnett --- src/components/views/right_panel/UserInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/right_panel/UserInfo.js b/src/components/views/right_panel/UserInfo.js index 9e0682e380..9db8de1ae3 100644 --- a/src/components/views/right_panel/UserInfo.js +++ b/src/components/views/right_panel/UserInfo.js @@ -141,7 +141,7 @@ async function verifyDevice(userId, device) { const cli = MatrixClientPeg.get(); const member = cli.getUser(userId); const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); - Modal.createTrackedDialog("Verification failed", "insecure", QuestionDialog, { + Modal.createTrackedDialog("Verification warning", "unverified session", QuestionDialog, { headerImage: require("../../../../res/img/e2e/warning.svg"), title: _t("Not Trusted"), description: