Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 34e2fd4

Browse files
authored
Merge pull request #4374 from matrix-org/jryans/backup-dialog-hellscape
Pass along key backup for bootstrap
2 parents 6416f40 + e1a496f commit 34e2fd4

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/CrossSigningManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export async function promptForBackupPassphrase() {
185185

186186
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
187187
const { finished } = Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog, {
188-
showSummary: false, keyCallback: k => key = k,
188+
showSummary: false, keyCallback: k => key = k,
189189
}, null, /* priority = */ false, /* static = */ true);
190190

191191
const success = await finished;

src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
7070
this._recoveryKey = null;
7171
this._recoveryKeyNode = null;
7272
this._setZxcvbnResultTimeout = null;
73+
this._backupKey = null;
7374

7475
this.state = {
7576
phase: PHASE_LOADING,
@@ -243,7 +244,15 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
243244
createSecretStorageKey: async () => this._recoveryKey,
244245
keyBackupInfo: this.state.backupInfo,
245246
setupNewKeyBackup: !this.state.backupInfo && this.state.useKeyBackup,
246-
getKeyBackupPassphrase: promptForBackupPassphrase,
247+
getKeyBackupPassphrase: () => {
248+
// We may already have the backup key if we earlier went
249+
// through the restore backup path, so pass it along
250+
// rather than prompting again.
251+
if (this._backupKey) {
252+
return this._backupKey;
253+
}
254+
return promptForBackupPassphrase();
255+
},
247256
});
248257
}
249258
this.setState({
@@ -272,10 +281,18 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
272281
}
273282

274283
_restoreBackup = async () => {
284+
// It's possible we'll need the backup key later on for bootstrapping,
285+
// so let's stash it here, rather than prompting for it twice.
286+
const keyCallback = k => this._backupKey = k;
287+
275288
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
276289
const { finished } = Modal.createTrackedDialog(
277-
'Restore Backup', '', RestoreKeyBackupDialog, {showSummary: false}, null,
278-
/* priority = */ false, /* static = */ false,
290+
'Restore Backup', '', RestoreKeyBackupDialog,
291+
{
292+
showSummary: false,
293+
keyCallback,
294+
},
295+
null, /* priority = */ false, /* static = */ false,
279296
);
280297

281298
await finished;

0 commit comments

Comments
 (0)