Use the New Session review dialog for verifying our own devices

This commit is contained in:
David Baker 2020-04-27 20:31:14 +01:00
parent 3bdd24ce83
commit ff1fd15e72
2 changed files with 59 additions and 38 deletions

View file

@ -191,17 +191,29 @@ function DeviceItem({userId, device}) {
device.getDisplayName(); device.getDisplayName();
let trustedLabel = null; let trustedLabel = null;
if (userTrust.isVerified()) trustedLabel = isVerified ? _t("Trusted") : _t("Not trusted"); if (userTrust.isVerified()) trustedLabel = isVerified ? _t("Trusted") : _t("Not trusted");
return (
<AccessibleButton
className={classes} if (isVerified) {
title={device.deviceId} return (
onClick={onDeviceClick} <div className={classes} title={device.deviceId} >
> <div className={iconClasses} />
<div className={iconClasses} /> <div className="mx_UserInfo_device_name">{deviceName}</div>
<div className="mx_UserInfo_device_name">{deviceName}</div> <div className="mx_UserInfo_device_trusted">{trustedLabel}</div>
<div className="mx_UserInfo_device_trusted">{trustedLabel}</div> </div>
</AccessibleButton> );
); } else {
return (
<AccessibleButton
className={classes}
title={device.deviceId}
onClick={onDeviceClick}
>
<div className={iconClasses} />
<div className="mx_UserInfo_device_name">{deviceName}</div>
<div className="mx_UserInfo_device_trusted">{trustedLabel}</div>
</AccessibleButton>
);
}
} }
function DevicesSection({devices, userId, loading}) { function DevicesSection({devices, userId, loading}) {

View file

@ -23,6 +23,7 @@ import {RIGHT_PANEL_PHASES} from "./stores/RightPanelStorePhases";
import {findDMForUser} from './createRoom'; import {findDMForUser} from './createRoom';
import {accessSecretStorage} from './CrossSigningManager'; import {accessSecretStorage} from './CrossSigningManager';
import SettingsStore from './settings/SettingsStore'; import SettingsStore from './settings/SettingsStore';
import NewSessionReviewDialog from './components/views/dialogs/NewSessionReviewDialog';
import {verificationMethods} from 'matrix-js-sdk/src/crypto'; import {verificationMethods} from 'matrix-js-sdk/src/crypto';
async function enable4SIfNeeded() { async function enable4SIfNeeded() {
@ -68,33 +69,41 @@ export async function verifyDevice(user, device) {
return; return;
} }
} }
Modal.createTrackedDialog("Verification warning", "unverified session", UntrustedDeviceDialog, {
user, if (user.userId === cli.getUserId()) {
device, Modal.createTrackedDialog('New Session Review', 'Starting dialog', NewSessionReviewDialog, {
onFinished: async (action) => { userId: user.userId,
if (action === "sas") { device,
const verificationRequestPromise = cli.legacyDeviceVerification( });
user.userId, } else {
device.deviceId, Modal.createTrackedDialog("Verification warning", "unverified session", UntrustedDeviceDialog, {
verificationMethods.SAS, user,
); device,
dis.dispatch({ onFinished: async (action) => {
action: "set_right_panel_phase", if (action === "sas") {
phase: RIGHT_PANEL_PHASES.EncryptionPanel, const verificationRequestPromise = cli.legacyDeviceVerification(
refireParams: {member: user, verificationRequestPromise}, user.userId,
}); device.deviceId,
} else if (action === "legacy") { verificationMethods.SAS,
const ManualDeviceKeyVerificationDialog = sdk.getComponent("dialogs.ManualDeviceKeyVerificationDialog"); );
Modal.createTrackedDialog("Legacy verify session", "legacy verify session", dis.dispatch({
ManualDeviceKeyVerificationDialog, action: "set_right_panel_phase",
{ phase: RIGHT_PANEL_PHASES.EncryptionPanel,
userId: user.userId, refireParams: {member: user, verificationRequestPromise},
device, });
}, } else if (action === "legacy") {
); const ManualDeviceKeyVerificationDialog = sdk.getComponent("dialogs.ManualDeviceKeyVerificationDialog");
} Modal.createTrackedDialog("Legacy verify session", "legacy verify session",
}, ManualDeviceKeyVerificationDialog,
}); {
userId: user.userId,
device,
},
);
}
},
});
}
} }
export async function legacyVerifyUser(user) { export async function legacyVerifyUser(user) {