You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Pass along key backup for bootstrap
If we ask for the key backup key early in creating secret storage to ensure we trust the backup, then we stash it to ensure it's available to bootstrap as well without prompting again. Fixes https://github.com/vector-im/riot-web/issues/12958
This commit is contained in:
@@ -70,6 +70,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
|
|||||||
this._recoveryKey = null;
|
this._recoveryKey = null;
|
||||||
this._recoveryKeyNode = null;
|
this._recoveryKeyNode = null;
|
||||||
this._setZxcvbnResultTimeout = null;
|
this._setZxcvbnResultTimeout = null;
|
||||||
|
this._backupKey = null;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
phase: PHASE_LOADING,
|
phase: PHASE_LOADING,
|
||||||
@@ -243,7 +244,15 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
|
|||||||
createSecretStorageKey: async () => this._recoveryKey,
|
createSecretStorageKey: async () => this._recoveryKey,
|
||||||
keyBackupInfo: this.state.backupInfo,
|
keyBackupInfo: this.state.backupInfo,
|
||||||
setupNewKeyBackup: !this.state.backupInfo && this.state.useKeyBackup,
|
setupNewKeyBackup: !this.state.backupInfo && this.state.useKeyBackup,
|
||||||
getKeyBackupPassphrase: promptForBackupPassphrase,
|
getKeyBackupPassphrase: () => {
|
||||||
|
// We may already have the backup key if we earlier went
|
||||||
|
// through the restore backup path, so pass it along
|
||||||
|
// rather than prompting again.
|
||||||
|
if (this._backupKey) {
|
||||||
|
return this._backupKey;
|
||||||
|
}
|
||||||
|
return promptForBackupPassphrase();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -272,10 +281,18 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_restoreBackup = async () => {
|
_restoreBackup = async () => {
|
||||||
|
// It's possible we'll need the backup key later on for bootstrapping,
|
||||||
|
// so let's stash it here, rather than prompting for it twice.
|
||||||
|
const keyCallback = k => this._backupKey = k;
|
||||||
|
|
||||||
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
|
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
|
||||||
const { finished } = Modal.createTrackedDialog(
|
const { finished } = Modal.createTrackedDialog(
|
||||||
'Restore Backup', '', RestoreKeyBackupDialog, {showSummary: false}, null,
|
'Restore Backup', '', RestoreKeyBackupDialog,
|
||||||
/* priority = */ false, /* static = */ false,
|
{
|
||||||
|
showSummary: false,
|
||||||
|
keyCallback,
|
||||||
|
},
|
||||||
|
null, /* priority = */ false, /* static = */ false,
|
||||||
);
|
);
|
||||||
|
|
||||||
await finished;
|
await finished;
|
||||||
|
|||||||
Reference in New Issue
Block a user