Support restoring key backup with stored secret
This commit is contained in:
parent
e87ff54eee
commit
458cc9598d
2 changed files with 37 additions and 12 deletions
|
@ -180,10 +180,23 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_restoreBackup = () => {
|
_restoreBackup = async () => {
|
||||||
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
|
// Use legacy path if backup key not stored in secret storage
|
||||||
Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog, {
|
if (!this.state.backupKeyStored) {
|
||||||
});
|
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
|
||||||
|
Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await accessSecretStorage(async () => {
|
||||||
|
await MatrixClientPeg.get().restoreKeyBackupWithSecretStorage(
|
||||||
|
this.state.backupInfo,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error restoring backup", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -340,6 +353,24 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
trustedLocally = _t("This backup is trusted because it has been restored on this device");
|
trustedLocally = _t("This backup is trusted because it has been restored on this device");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let buttonRow = (
|
||||||
|
<div className="mx_KeyBackupPanel_buttonRow">
|
||||||
|
<AccessibleButton kind="primary" onClick={this._restoreBackup}>
|
||||||
|
{restoreButtonCaption}
|
||||||
|
</AccessibleButton>
|
||||||
|
<AccessibleButton kind="danger" onClick={this._deleteBackup}>
|
||||||
|
{_t("Delete Backup")}
|
||||||
|
</AccessibleButton>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
if (this.state.backupKeyStored && !SettingsStore.isFeatureEnabled("feature_cross_signing")) {
|
||||||
|
buttonRow = <p>⚠️ {_t(
|
||||||
|
"Backup key stored in secret storage, but this feature is not " +
|
||||||
|
"enabled on this device. Please enable cross-signing in Labs to " +
|
||||||
|
"modify key backup state.",
|
||||||
|
)}</p>;
|
||||||
|
}
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<div>{clientBackupStatus}</div>
|
<div>{clientBackupStatus}</div>
|
||||||
<details>
|
<details>
|
||||||
|
@ -351,14 +382,7 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
<div>{backupSigStatuses}</div>
|
<div>{backupSigStatuses}</div>
|
||||||
<div>{trustedLocally}</div>
|
<div>{trustedLocally}</div>
|
||||||
</details>
|
</details>
|
||||||
<div className="mx_KeyBackupPanel_buttonRow">
|
{buttonRow}
|
||||||
<AccessibleButton kind="primary" onClick={this._restoreBackup}>
|
|
||||||
{restoreButtonCaption}
|
|
||||||
</AccessibleButton>
|
|
||||||
<AccessibleButton kind="danger" onClick={this._deleteBackup}>
|
|
||||||
{ _t("Delete Backup") }
|
|
||||||
</AccessibleButton>
|
|
||||||
</div>
|
|
||||||
</div>;
|
</div>;
|
||||||
} else {
|
} else {
|
||||||
// This is a temporary button for testing the new path which stores
|
// This is a temporary button for testing the new path which stores
|
||||||
|
|
|
@ -545,6 +545,7 @@
|
||||||
"Backup has an <validity>invalid</validity> signature from <verify>unverified</verify> device <device></device>": "Backup has an <validity>invalid</validity> signature from <verify>unverified</verify> device <device></device>",
|
"Backup has an <validity>invalid</validity> signature from <verify>unverified</verify> device <device></device>": "Backup has an <validity>invalid</validity> signature from <verify>unverified</verify> device <device></device>",
|
||||||
"Backup is not signed by any of your devices": "Backup is not signed by any of your devices",
|
"Backup is not signed by any of your devices": "Backup is not signed by any of your devices",
|
||||||
"This backup is trusted because it has been restored on this device": "This backup is trusted because it has been restored on this device",
|
"This backup is trusted because it has been restored on this device": "This backup is trusted because it has been restored on this device",
|
||||||
|
"Backup key stored in secret storage, but this feature is not enabled on this device. Please enable cross-signing in Labs to modify key backup state.": "Backup key stored in secret storage, but this feature is not enabled on this device. Please enable cross-signing in Labs to modify key backup state.",
|
||||||
"Backup version: ": "Backup version: ",
|
"Backup version: ": "Backup version: ",
|
||||||
"Algorithm: ": "Algorithm: ",
|
"Algorithm: ": "Algorithm: ",
|
||||||
"Backup key stored: ": "Backup key stored: ",
|
"Backup key stored: ": "Backup key stored: ",
|
||||||
|
|
Loading…
Reference in a new issue