Merge pull request #4291 from matrix-org/bwindels/fixcantdismissdevicetoast
Fix: can't dismiss unverified session toast when encryption hasn't been upgraded
This commit is contained in:
commit
7bdd22ae03
1 changed files with 67 additions and 71 deletions
|
@ -119,89 +119,85 @@ export default class DeviceListener {
|
||||||
|
|
||||||
const crossSigningReady = await cli.isCrossSigningReady();
|
const crossSigningReady = await cli.isCrossSigningReady();
|
||||||
|
|
||||||
if (!crossSigningReady) {
|
if (this._dismissedThisDeviceToast) {
|
||||||
if (this._dismissedThisDeviceToast) {
|
ToastStore.sharedInstance().dismissToast(THIS_DEVICE_TOAST_KEY);
|
||||||
ToastStore.sharedInstance().dismissToast(THIS_DEVICE_TOAST_KEY);
|
} else {
|
||||||
return;
|
if (!crossSigningReady) {
|
||||||
}
|
// cross signing isn't enabled - nag to enable it
|
||||||
|
// There are 3 different toasts for:
|
||||||
// cross signing isn't enabled - nag to enable it
|
if (cli.getStoredCrossSigningForUser(cli.getUserId())) {
|
||||||
// There are 3 different toasts for:
|
// Cross-signing on account but this device doesn't trust the master key (verify this session)
|
||||||
if (cli.getStoredCrossSigningForUser(cli.getUserId())) {
|
|
||||||
// Cross-signing on account but this device doesn't trust the master key (verify this session)
|
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
|
||||||
key: THIS_DEVICE_TOAST_KEY,
|
|
||||||
title: _t("Verify this session"),
|
|
||||||
icon: "verification_warning",
|
|
||||||
props: {kind: 'verify_this_session'},
|
|
||||||
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const backupInfo = await this._getKeyBackupInfo();
|
|
||||||
if (backupInfo) {
|
|
||||||
// No cross-signing on account but key backup available (upgrade encryption)
|
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
key: THIS_DEVICE_TOAST_KEY,
|
key: THIS_DEVICE_TOAST_KEY,
|
||||||
title: _t("Encryption upgrade available"),
|
title: _t("Verify this session"),
|
||||||
icon: "verification_warning",
|
icon: "verification_warning",
|
||||||
props: {kind: 'upgrade_encryption'},
|
props: {kind: 'verify_this_session'},
|
||||||
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// No cross-signing or key backup on account (set up encryption)
|
const backupInfo = await this._getKeyBackupInfo();
|
||||||
|
if (backupInfo) {
|
||||||
|
// No cross-signing on account but key backup available (upgrade encryption)
|
||||||
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
|
key: THIS_DEVICE_TOAST_KEY,
|
||||||
|
title: _t("Encryption upgrade available"),
|
||||||
|
icon: "verification_warning",
|
||||||
|
props: {kind: 'upgrade_encryption'},
|
||||||
|
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// No cross-signing or key backup on account (set up encryption)
|
||||||
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
|
key: THIS_DEVICE_TOAST_KEY,
|
||||||
|
title: _t("Set up encryption"),
|
||||||
|
icon: "verification_warning",
|
||||||
|
props: {kind: 'set_up_encryption'},
|
||||||
|
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (await cli.secretStorageKeyNeedsUpgrade()) {
|
||||||
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
|
key: THIS_DEVICE_TOAST_KEY,
|
||||||
|
title: _t("Encryption upgrade available"),
|
||||||
|
icon: "verification_warning",
|
||||||
|
props: {kind: 'upgrade_ssss'},
|
||||||
|
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// as long as cross-signing isn't ready,
|
||||||
|
// you can't see or dismiss any device toasts
|
||||||
|
if (crossSigningReady) {
|
||||||
|
const newActiveToasts = new Set();
|
||||||
|
|
||||||
|
const devices = await cli.getStoredDevicesForUser(cli.getUserId());
|
||||||
|
for (const device of devices) {
|
||||||
|
if (device.deviceId == cli.deviceId) continue;
|
||||||
|
|
||||||
|
const deviceTrust = await cli.checkDeviceTrust(cli.getUserId(), device.deviceId);
|
||||||
|
if (deviceTrust.isCrossSigningVerified() || this._dismissed.has(device.deviceId)) {
|
||||||
|
ToastStore.sharedInstance().dismissToast(toastKey(device.deviceId));
|
||||||
|
} else {
|
||||||
|
this._activeNagToasts.add(device.deviceId);
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
key: THIS_DEVICE_TOAST_KEY,
|
key: toastKey(device.deviceId),
|
||||||
title: _t("Set up encryption"),
|
title: _t("Unverified login. Was this you?"),
|
||||||
icon: "verification_warning",
|
icon: "verification_warning",
|
||||||
props: {kind: 'set_up_encryption'},
|
props: { device },
|
||||||
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
component: sdk.getComponent("toasts.UnverifiedSessionToast"),
|
||||||
});
|
});
|
||||||
|
newActiveToasts.add(device.deviceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else if (await cli.secretStorageKeyNeedsUpgrade()) {
|
// clear any other outstanding toasts (eg. logged out devices)
|
||||||
if (this._dismissedThisDeviceToast) {
|
for (const deviceId of this._activeNagToasts) {
|
||||||
ToastStore.sharedInstance().dismissToast(THIS_DEVICE_TOAST_KEY);
|
if (!newActiveToasts.has(deviceId)) ToastStore.sharedInstance().dismissToast(toastKey(deviceId));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
this._activeNagToasts = newActiveToasts;
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
|
||||||
key: THIS_DEVICE_TOAST_KEY,
|
|
||||||
title: _t("Encryption upgrade available"),
|
|
||||||
icon: "verification_warning",
|
|
||||||
props: {kind: 'upgrade_ssss'},
|
|
||||||
component: sdk.getComponent("toasts.SetupEncryptionToast"),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ToastStore.sharedInstance().dismissToast(THIS_DEVICE_TOAST_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newActiveToasts = new Set();
|
|
||||||
|
|
||||||
const devices = await cli.getStoredDevicesForUser(cli.getUserId());
|
|
||||||
for (const device of devices) {
|
|
||||||
if (device.deviceId == cli.deviceId) continue;
|
|
||||||
|
|
||||||
const deviceTrust = await cli.checkDeviceTrust(cli.getUserId(), device.deviceId);
|
|
||||||
if (deviceTrust.isCrossSigningVerified() || this._dismissed.has(device.deviceId)) {
|
|
||||||
ToastStore.sharedInstance().dismissToast(toastKey(device.deviceId));
|
|
||||||
} else {
|
|
||||||
this._activeNagToasts.add(device.deviceId);
|
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
|
||||||
key: toastKey(device.deviceId),
|
|
||||||
title: _t("Unverified login. Was this you?"),
|
|
||||||
icon: "verification_warning",
|
|
||||||
props: { device },
|
|
||||||
component: sdk.getComponent("toasts.UnverifiedSessionToast"),
|
|
||||||
});
|
|
||||||
newActiveToasts.add(device.deviceId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear any other outstanding toasts (eg. logged out devices)
|
|
||||||
for (const deviceId of this._activeNagToasts) {
|
|
||||||
if (!newActiveToasts.has(deviceId)) ToastStore.sharedInstance().dismissToast(toastKey(deviceId));
|
|
||||||
}
|
|
||||||
this._activeNagToasts = newActiveToasts;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue