Skip to content

Commit

Permalink
fix: handle keyParams and auth_params in import
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Sep 7, 2020
1 parent 157b6c5 commit 3b525ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 11 additions & 12 deletions app/assets/javascripts/directives/views/accountMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
STRING_GENERATING_REGISTER_KEYS,
StringImportError
} from '@/strings';
import { STRING_IMPORT_FAILED_NEWER_BACKUP } from '../../strings';

const ELEMENT_ID_IMPORT_PASSWORD_INPUT = 'import-password-request';

Expand Down Expand Up @@ -204,7 +205,7 @@ class AccountMenuCtrl extends PureCtrl {
text: STRING_NON_MATCHING_PASSWORDS
});
return;
}
}
await this.setFormDataState({
confirmPassword: false,
status: STRING_GENERATING_REGISTER_KEYS,
Expand Down Expand Up @@ -336,7 +337,7 @@ class AccountMenuCtrl extends PureCtrl {
}

/**
* @template
* @template
*/
async importFileSelected(files) {
const run = async () => {
Expand Down Expand Up @@ -377,17 +378,15 @@ class AccountMenuCtrl extends PureCtrl {
}

async performImport(data, password) {
if (data.keyParams) {
if (Number(data.keyParams.version) > 3) {
this.setState({
importData: null
});
this.alertManager.alert({
text: "This backup file was created using a later version of the application and cannot be imported."
});
return;
}
if (
data.keyParams ||
(data.auth_params && Number(data.auth_params.version) > protocolManager.version())
) {
this.setState({ importData: null });
this.alertManager.alert({ text: STRING_IMPORT_FAILED_NEWER_BACKUP });
return;
}

await this.setState({
importData: {
...this.state.importData,
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ export function StringImportError({errorCount}) {

/** @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.";

export const STRING_IMPORT_FAILED_NEWER_BACKUP = "This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.";

0 comments on commit 3b525ae

Please sign in to comment.