fix: display error message if backup file is from an unsupported version (#463)

This commit is contained in:
Baptiste Grob
2020-09-07 15:29:10 +02:00
committed by GitHub
parent 405ac65be4
commit 148f7d7603
2 changed files with 10 additions and 2 deletions

View File

@@ -19,12 +19,13 @@ import {
STRING_GENERATING_REGISTER_KEYS,
StringImportError,
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_CHANGE,
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL,
STRING_UNSUPPORTED_BACKUP_FILE_VERSION
} from '@/strings';
import { SyncOpStatus } from 'snjs/dist/@types/services/sync/sync_op_status';
import { PasswordWizardType } from '@/types';
import { BackupFile } from 'snjs/dist/@types/services/protocol_service';
import { confirmDialog } from '@/services/alertService';
import { confirmDialog, alertDialog } from '@/services/alertService';
const ELEMENT_ID_IMPORT_PASSWORD_INPUT = 'import-password-request';
@@ -375,6 +376,12 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
return;
}
if (data.auth_params || data.keyParams) {
const version = data.keyParams?.version || data.auth_params?.version;
if (!this.application!.protocolService!.supportedVersions().includes(version)) {
await this.setState({ importData: null });
alertDialog({ text: STRING_UNSUPPORTED_BACKUP_FILE_VERSION });
return;
}
await this.setState({
importData: {
...this.getState().importData,

View File

@@ -51,6 +51,7 @@ export const STRING_ENTER_ACCOUNT_PASSWORD = 'Enter your account password';
export const STRING_ENTER_PASSCODE_FOR_MIGRATION = 'Your application passcode is required to perform an upgrade of your local data storage structure.';
export const STRING_STORAGE_UPDATE = 'Storage Update';
export const STRING_AUTHENTICATION_REQUIRED = 'Authentication Required';
export const STRING_UNSUPPORTED_BACKUP_FILE_VERSION = 'This backup file was created using an unsupported version of the application and cannot be imported here. Please update your application and try again.';
/** @password_change */
export const STRING_FAILED_PASSWORD_CHANGE = "There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup.";