diff --git a/src/DeviceListener.ts b/src/DeviceListener.ts index 1f49c3b34d..6142621c31 100644 --- a/src/DeviceListener.ts +++ b/src/DeviceListener.ts @@ -306,6 +306,9 @@ export default class DeviceListener { // Unverified devices that have appeared since then const newUnverifiedDeviceIds = new Set(); + const isCurrentDeviceTrusted = crossSigningReady && + await (cli.checkDeviceTrust(cli.getUserId()!, cli.deviceId!)).isCrossSigningVerified(); + // as long as cross-signing isn't ready, // you can't see or dismiss any device toasts if (crossSigningReady) { @@ -313,7 +316,7 @@ export default class DeviceListener { for (const device of devices) { if (device.deviceId === cli.deviceId) continue; - const deviceTrust = await cli.checkDeviceTrust(cli.getUserId(), device.deviceId); + const deviceTrust = await cli.checkDeviceTrust(cli.getUserId()!, device.deviceId!); if (!deviceTrust.isCrossSigningVerified() && !this.dismissed.has(device.deviceId)) { if (this.ourDeviceIdsAtStart.has(device.deviceId)) { oldUnverifiedDeviceIds.add(device.deviceId); @@ -329,7 +332,8 @@ export default class DeviceListener { logger.debug("Currently showing toasts for: " + Array.from(this.displayingToastsForDeviceIds).join(',')); // Display or hide the batch toast for old unverified sessions - if (oldUnverifiedDeviceIds.size > 0) { + // don't show the toast if the current device is unverified + if (oldUnverifiedDeviceIds.size > 0 && isCurrentDeviceTrusted) { showBulkUnverifiedSessionsToast(oldUnverifiedDeviceIds); } else { hideBulkUnverifiedSessionsToast(); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7e8ba41bfa..6a6e9e80a9 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -809,7 +809,7 @@ "Yes": "Yes", "No": "No", "Help improve %(analyticsOwner)s": "Help improve %(analyticsOwner)s", - "You have unverified logins": "You have unverified logins", + "You have unverified sessions": "You have unverified sessions", "Review to ensure your account is safe": "Review to ensure your account is safe", "Review": "Review", "Later": "Later", diff --git a/src/toasts/BulkUnverifiedSessionsToast.ts b/src/toasts/BulkUnverifiedSessionsToast.ts index 0113f2f030..ae512df7ed 100644 --- a/src/toasts/BulkUnverifiedSessionsToast.ts +++ b/src/toasts/BulkUnverifiedSessionsToast.ts @@ -38,7 +38,7 @@ export const showToast = (deviceIds: Set) => { ToastStore.sharedInstance().addOrReplaceToast({ key: TOAST_KEY, - title: _t("You have unverified logins"), + title: _t("You have unverified sessions"), icon: "verification_warning", props: { description: _t("Review to ensure your account is safe"), diff --git a/test/DeviceListener-test.ts b/test/DeviceListener-test.ts index 3e76af5bb7..527a7f8c7b 100644 --- a/test/DeviceListener-test.ts +++ b/test/DeviceListener-test.ts @@ -414,11 +414,16 @@ describe('DeviceListener', () => { expect(BulkUnverifiedSessionsToast.showToast).not.toHaveBeenCalled(); }); - it('hides toast when only unverified device is the current device', async () => { - mockClient!.getStoredDevicesForUser.mockReturnValue([ - currentDevice, - ]); - mockClient!.checkDeviceTrust.mockReturnValue(deviceTrustUnverified); + it('hides toast when current device is unverified', async () => { + // device2 verified, current and device3 unverified + mockClient!.checkDeviceTrust.mockImplementation((_userId, deviceId) => { + switch (deviceId) { + case device2.deviceId: + return deviceTrustVerified; + default: + return deviceTrustUnverified; + } + }); await createAndStart(); expect(BulkUnverifiedSessionsToast.hideToast).toHaveBeenCalled(); expect(BulkUnverifiedSessionsToast.showToast).not.toHaveBeenCalled();