Merge pull request #2435 from matrix-org/dbkr/dialog_trusted_new_backup
Different dialog for new trusted backup
This commit is contained in:
commit
2a20d9d67e
3 changed files with 83 additions and 42 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018-2019 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -24,9 +24,15 @@ import Modal from "../../../../Modal";
|
||||||
|
|
||||||
export default class NewRecoveryMethodDialog extends React.PureComponent {
|
export default class NewRecoveryMethodDialog extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
// As returned by js-sdk getKeyBackupVersion()
|
||||||
|
newVersionInfo: PropTypes.object,
|
||||||
onFinished: PropTypes.func.isRequired,
|
onFinished: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onOkClick = () => {
|
||||||
|
this.props.onFinished();
|
||||||
|
}
|
||||||
|
|
||||||
onGoToSettingsClick = () => {
|
onGoToSettingsClick = () => {
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
dis.dispatch({ action: 'view_user_settings' });
|
dis.dispatch({ action: 'view_user_settings' });
|
||||||
|
@ -41,8 +47,7 @@ export default class NewRecoveryMethodDialog extends React.PureComponent {
|
||||||
// sending our own new keys to it.
|
// sending our own new keys to it.
|
||||||
let backupSigStatus;
|
let backupSigStatus;
|
||||||
try {
|
try {
|
||||||
const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
|
backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(this.props.newVersionInfo);
|
||||||
backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Unable to fetch key backup status", e);
|
console.log("Unable to fetch key backup status", e);
|
||||||
return;
|
return;
|
||||||
|
@ -76,34 +81,57 @@ export default class NewRecoveryMethodDialog extends React.PureComponent {
|
||||||
{_t("New Recovery Method")}
|
{_t("New Recovery Method")}
|
||||||
</span>;
|
</span>;
|
||||||
|
|
||||||
|
const newMethodDetected = <p>{_t(
|
||||||
|
"A new recovery passphrase and key for Secure " +
|
||||||
|
"Messages have been detected.",
|
||||||
|
)}</p>;
|
||||||
|
|
||||||
|
const hackWarning = <p className="warning">{_t(
|
||||||
|
"If you didn't set the new recovery method, an " +
|
||||||
|
"attacker may be trying to access your account. " +
|
||||||
|
"Change your account password and set a new recovery " +
|
||||||
|
"method immediately in Settings.",
|
||||||
|
)}</p>;
|
||||||
|
|
||||||
|
let content;
|
||||||
|
if (MatrixClientPeg.get().getKeyBackupEnabled()) {
|
||||||
|
content = <div>
|
||||||
|
{newMethodDetected}
|
||||||
|
<p>{_t(
|
||||||
|
"This device is encrypting history using the new recovery method.",
|
||||||
|
)}</p>
|
||||||
|
{hackWarning}
|
||||||
|
<DialogButtons
|
||||||
|
primaryButton={_t("OK")}
|
||||||
|
onPrimaryButtonClick={this.onOkClick}
|
||||||
|
cancelButton={_t("Go to Settings")}
|
||||||
|
onCancel={this.onGoToSettingsClick}
|
||||||
|
/>
|
||||||
|
</div>;
|
||||||
|
} else {
|
||||||
|
content = <div>
|
||||||
|
{newMethodDetected}
|
||||||
|
<p>{_t(
|
||||||
|
"Setting up Secure Messages on this device " +
|
||||||
|
"will re-encrypt this device's message history with " +
|
||||||
|
"the new recovery method.",
|
||||||
|
)}</p>
|
||||||
|
{hackWarning}
|
||||||
|
<DialogButtons
|
||||||
|
primaryButton={_t("Set up Secure Messages")}
|
||||||
|
onPrimaryButtonClick={this.onSetupClick}
|
||||||
|
cancelButton={_t("Go to Settings")}
|
||||||
|
onCancel={this.onGoToSettingsClick}
|
||||||
|
/>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseDialog className="mx_KeyBackupFailedDialog"
|
<BaseDialog className="mx_KeyBackupFailedDialog"
|
||||||
onFinished={this.props.onFinished}
|
onFinished={this.props.onFinished}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
<div>
|
{content}
|
||||||
<p>{_t(
|
|
||||||
"A new recovery passphrase and key for Secure " +
|
|
||||||
"Messages have been detected.",
|
|
||||||
)}</p>
|
|
||||||
<p>{_t(
|
|
||||||
"Setting up Secure Messages on this device " +
|
|
||||||
"will re-encrypt this device's message history with " +
|
|
||||||
"the new recovery method.",
|
|
||||||
)}</p>
|
|
||||||
<p className="warning">{_t(
|
|
||||||
"If you didn't set the new recovery method, an " +
|
|
||||||
"attacker may be trying to access your account. " +
|
|
||||||
"Change your account password and set a new recovery " +
|
|
||||||
"method immediately in Settings.",
|
|
||||||
)}</p>
|
|
||||||
<DialogButtons
|
|
||||||
primaryButton={_t("Set up Secure Messages")}
|
|
||||||
onPrimaryButtonClick={this.onSetupClick}
|
|
||||||
cancelButton={_t("Go to Settings")}
|
|
||||||
onCancel={this.onGoToSettingsClick}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
Copyright 2017, 2018 New Vector Ltd
|
Copyright 2017-2019 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -1447,20 +1447,32 @@ export default React.createClass({
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cli.on("crypto.keyBackupFailed", (errcode) => {
|
cli.on("crypto.keyBackupFailed", async (errcode) => {
|
||||||
switch (errcode) {
|
let haveNewVersion;
|
||||||
case 'M_NOT_FOUND':
|
let newVersionInfo;
|
||||||
Modal.createTrackedDialogAsync('Recovery Method Removed', 'Recovery Method Removed',
|
// if key backup is still enabled, there must be a new backup in place
|
||||||
import('../../async-components/views/dialogs/keybackup/RecoveryMethodRemovedDialog'),
|
if (MatrixClientPeg.get().getKeyBackupEnabled()) {
|
||||||
);
|
haveNewVersion = true;
|
||||||
|
} else {
|
||||||
|
// otherwise check the server to see if there's a new one
|
||||||
|
try {
|
||||||
|
newVersionInfo = await MatrixClientPeg.get().getKeyBackupVersion();
|
||||||
|
if (newVersionInfo !== null) haveNewVersion = true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Saw key backup error but failed to check backup version!", e);
|
||||||
return;
|
return;
|
||||||
case 'M_WRONG_ROOM_KEYS_VERSION':
|
}
|
||||||
Modal.createTrackedDialogAsync('New Recovery Method', 'New Recovery Method',
|
}
|
||||||
import('../../async-components/views/dialogs/keybackup/NewRecoveryMethodDialog'),
|
|
||||||
);
|
if (haveNewVersion) {
|
||||||
return;
|
Modal.createTrackedDialogAsync('New Recovery Method', 'New Recovery Method',
|
||||||
default:
|
import('../../async-components/views/dialogs/keybackup/NewRecoveryMethodDialog'),
|
||||||
console.error(`Invalid key backup failure code: ${errcode}`);
|
{ newVersionInfo },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Modal.createTrackedDialogAsync('Recovery Method Removed', 'Recovery Method Removed',
|
||||||
|
import('../../async-components/views/dialogs/keybackup/RecoveryMethodRemovedDialog'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1410,10 +1410,11 @@
|
||||||
"If you don't want to set this up now, you can later in Settings.": "If you don't want to set this up now, you can later in Settings.",
|
"If you don't want to set this up now, you can later in Settings.": "If you don't want to set this up now, you can later in Settings.",
|
||||||
"New Recovery Method": "New Recovery Method",
|
"New Recovery Method": "New Recovery Method",
|
||||||
"A new recovery passphrase and key for Secure Messages have been detected.": "A new recovery passphrase and key for Secure Messages have been detected.",
|
"A new recovery passphrase and key for Secure Messages have been detected.": "A new recovery passphrase and key for Secure Messages have been detected.",
|
||||||
"Setting up Secure Messages on this device will re-encrypt this device's message history with the new recovery method.": "Setting up Secure Messages on this device will re-encrypt this device's message history with the new recovery method.",
|
|
||||||
"If you didn't set the new recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.": "If you didn't set the new recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.",
|
"If you didn't set the new recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.": "If you didn't set the new recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.",
|
||||||
"Set up Secure Messages": "Set up Secure Messages",
|
"This device is encrypting history using the new recovery method.": "This device is encrypting history using the new recovery method.",
|
||||||
"Go to Settings": "Go to Settings",
|
"Go to Settings": "Go to Settings",
|
||||||
|
"Setting up Secure Messages on this device will re-encrypt this device's message history with the new recovery method.": "Setting up Secure Messages on this device will re-encrypt this device's message history with the new recovery method.",
|
||||||
|
"Set up Secure Messages": "Set up Secure Messages",
|
||||||
"Recovery Method Removed": "Recovery Method Removed",
|
"Recovery Method Removed": "Recovery Method Removed",
|
||||||
"This device has detected that your recovery passphrase and key for Secure Messages have been removed.": "This device has detected that your recovery passphrase and key for Secure Messages have been removed.",
|
"This device has detected that your recovery passphrase and key for Secure Messages have been removed.": "This device has detected that your recovery passphrase and key for Secure Messages have been removed.",
|
||||||
"If you did this accidentally, you can setup Secure Messages on this device which will re-encrypt this device's message history with a new recovery method.": "If you did this accidentally, you can setup Secure Messages on this device which will re-encrypt this device's message history with a new recovery method.",
|
"If you did this accidentally, you can setup Secure Messages on this device which will re-encrypt this device's message history with a new recovery method.": "If you did this accidentally, you can setup Secure Messages on this device which will re-encrypt this device's message history with a new recovery method.",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue