Privileges for downloading backup from password wizard

This commit is contained in:
Mo Bitar
2018-12-13 12:24:30 -06:00
parent c08a33fd57
commit bc634ca7da
3 changed files with 35 additions and 34 deletions

View File

@@ -351,17 +351,7 @@ class AccountMenu {
*/
$scope.downloadDataArchive = async function() {
let run = () => {
archiveManager.downloadBackup($scope.archiveFormData.encrypted);
}
if(await privilegesManager.actionRequiresPrivilege(PrivilegesManager.ActionManageBackups)) {
privilegesManager.presentPrivilegesModal(PrivilegesManager.ActionManageBackups, () => {
run();
});
} else {
run();
}
archiveManager.downloadBackup($scope.archiveFormData.encrypted);
}
/*

View File

@@ -1,9 +1,10 @@
class ArchiveManager {
constructor(passcodeManager, authManager, modelManager) {
constructor(passcodeManager, authManager, modelManager, privilegesManager) {
this.passcodeManager = passcodeManager;
this.authManager = authManager;
this.modelManager = modelManager;
this.privilegesManager = privilegesManager;
}
/*
@@ -15,26 +16,36 @@ class ArchiveManager {
}
async downloadBackupOfItems(items, encrypted) {
// download in Standard File format
var keys, authParams;
if(encrypted) {
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
keys = this.passcodeManager.keys();
authParams = this.passcodeManager.passcodeAuthParams();
} else {
keys = await this.authManager.keys();
authParams = await this.authManager.getAuthParams();
let run = async () => {
// download in Standard File format
var keys, authParams;
if(encrypted) {
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
keys = this.passcodeManager.keys();
authParams = this.passcodeManager.passcodeAuthParams();
} else {
keys = await this.authManager.keys();
authParams = await this.authManager.getAuthParams();
}
}
}
this.__itemsData(items, keys, authParams).then((data) => {
let modifier = encrypted ? "Encrypted" : "Decrypted";
this.__downloadData(data, `Standard Notes ${modifier} Backup - ${this.__formattedDate()}.txt`);
this.__itemsData(items, keys, authParams).then((data) => {
let modifier = encrypted ? "Encrypted" : "Decrypted";
this.__downloadData(data, `Standard Notes ${modifier} Backup - ${this.__formattedDate()}.txt`);
// download as zipped plain text files
if(!keys) {
this.__downloadZippedItems(items);
}
})
// download as zipped plain text files
if(!keys) {
this.__downloadZippedItems(items);
}
})
}
if(await this.privilegesManager.actionRequiresPrivilege(PrivilegesManager.ActionManageBackups)) {
this.privilegesManager.presentPrivilegesModal(PrivilegesManager.ActionManageBackups, () => {
run();
});
} else {
run();
}
}
/*

View File

@@ -11,7 +11,7 @@
%div{"ng-if" => "step == 0"}
%div{"ng-if" => "changePassword"}
%p.sk-p
%p.sk-p.sk-panel-row
Changing your password involves changing your encryption key, which requires your data to be re-encrypted and synced.
If you have many items, syncing your data can take several minutes.
%p.sk-p.sk-panel-row You must keep the application window open during this process.
@@ -50,9 +50,9 @@
%p.sk-p.bold.sk-panel-row.info-i Please sign out of all applications (excluding this one), including:
%ul
%li Desktop
%li Web (Chrome, Firefox, Safari)
%li Mobile (iOS and Android)
%li.sk-p Desktop
%li.sk-p Web (Chrome, Firefox, Safari)
%li.sk-p Mobile (iOS and Android)
%p.sk-p.sk-panel-row
If you do not currently have access to a device you're signed in on, you may proceed,
but must make signing out and back in the first step upon gaining access to that device.