Key Backup: Don't fail if no keys
Only fail if there were any keys in the backup (which does mean that the backup will always succeed if there aren't any keys which could also be misleading, but is probably not as bad and can probably be fixed with Trust on Decrypt). Also cheekily fix the error message so it talks about passphrases if you used a passphrase and recovery keys if you used a recovery key.pull/21833/head
parent
ce2066b741
commit
ce565f109a
|
@ -21,6 +21,9 @@ import Modal from '../../../../Modal';
|
||||||
|
|
||||||
import { _t } from '../../../../languageHandler';
|
import { _t } from '../../../../languageHandler';
|
||||||
|
|
||||||
|
const RESTORE_TYPE_PASSPHRASE = 0;
|
||||||
|
const RESTORE_TYPE_RECOVERYKEY = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for restoring e2e keys from a backup and the user's recovery key
|
* Dialog for restoring e2e keys from a backup and the user's recovery key
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +39,7 @@ export default React.createClass({
|
||||||
recoveryKeyValid: false,
|
recoveryKeyValid: false,
|
||||||
forceRecoveryKey: false,
|
forceRecoveryKey: false,
|
||||||
passPhrase: '',
|
passPhrase: '',
|
||||||
|
restoreType: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -80,6 +84,7 @@ export default React.createClass({
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true,
|
loading: true,
|
||||||
restoreError: null,
|
restoreError: null,
|
||||||
|
restoreType: RESTORE_TYPE_PASSPHRASE,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithPassword(
|
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithPassword(
|
||||||
|
@ -102,6 +107,7 @@ export default React.createClass({
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true,
|
loading: true,
|
||||||
restoreError: null,
|
restoreError: null,
|
||||||
|
restoreType: RESTORE_TYPE_PASSPHRASE,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithRecoveryKey(
|
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithRecoveryKey(
|
||||||
|
@ -184,14 +190,27 @@ export default React.createClass({
|
||||||
} else if (this.state.backupInfo === null) {
|
} else if (this.state.backupInfo === null) {
|
||||||
title = _t("Error");
|
title = _t("Error");
|
||||||
content = _t("No backup found!");
|
content = _t("No backup found!");
|
||||||
} else if (this.state.recoverInfo && this.state.recoverInfo.imported === 0) {
|
} else if (
|
||||||
|
this.state.recoverInfo &&
|
||||||
|
this.state.recoverInfo.imported === 0 &&
|
||||||
|
this.state.recoverInfo.total > 0
|
||||||
|
) {
|
||||||
title = _t("Error Restoring Backup");
|
title = _t("Error Restoring Backup");
|
||||||
|
if (this.state.restoreType === RESTORE_TYPE_RECOVERYKEY) {
|
||||||
content = <div>
|
content = <div>
|
||||||
<p>{_t(
|
<p>{_t(
|
||||||
"Backup could not be decrypted with this key: " +
|
"Backup could not be decrypted with this key: " +
|
||||||
"please verify that you entered the correct recovery key.",
|
"please verify that you entered the correct recovery key.",
|
||||||
)}</p>
|
)}</p>
|
||||||
</div>;
|
</div>;
|
||||||
|
} else {
|
||||||
|
content = <div>
|
||||||
|
<p>{_t(
|
||||||
|
"Backup could not be decrypted with this passphrase: " +
|
||||||
|
"please verify that you entered the correct recovery passphrase.",
|
||||||
|
)}</p>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
} else if (this.state.recoverInfo) {
|
} else if (this.state.recoverInfo) {
|
||||||
title = _t("Backup Restored");
|
title = _t("Backup Restored");
|
||||||
let failedToDecrypt;
|
let failedToDecrypt;
|
||||||
|
|
|
@ -1120,6 +1120,7 @@
|
||||||
"No backup found!": "No backup found!",
|
"No backup found!": "No backup found!",
|
||||||
"Error Restoring Backup": "Error Restoring Backup",
|
"Error Restoring Backup": "Error Restoring Backup",
|
||||||
"Backup could not be decrypted with this key: please verify that you entered the correct recovery key.": "Backup could not be decrypted with this key: please verify that you entered the correct recovery key.",
|
"Backup could not be decrypted with this key: please verify that you entered the correct recovery key.": "Backup could not be decrypted with this key: please verify that you entered the correct recovery key.",
|
||||||
|
"Backup could not be decrypted with this passphrase: please verify that you entered the correct recovery passphrase.": "Backup could not be decrypted with this passphrase: please verify that you entered the correct recovery passphrase.",
|
||||||
"Backup Restored": "Backup Restored",
|
"Backup Restored": "Backup Restored",
|
||||||
"Failed to decrypt %(failedCount)s sessions!": "Failed to decrypt %(failedCount)s sessions!",
|
"Failed to decrypt %(failedCount)s sessions!": "Failed to decrypt %(failedCount)s sessions!",
|
||||||
"Restored %(sessionCount)s session keys": "Restored %(sessionCount)s session keys",
|
"Restored %(sessionCount)s session keys": "Restored %(sessionCount)s session keys",
|
||||||
|
|
Loading…
Reference in New Issue