mirror of
https://github.com/nextcloud/passman.git
synced 2025-09-14 08:54:26 +08:00
fix delete/recover credential button actions
This commit is contained in:
parent
f97567d7f6
commit
2018d422d0
4 changed files with 50 additions and 37 deletions
|
@ -58,6 +58,7 @@ class TranslationController extends ApiController {
|
|||
'credential.recovered' => $this->trans->t('Credential recovered'),
|
||||
'credential.destroyed' => $this->trans->t('Credential destroyed'),
|
||||
'error.loading.file.perm' => $this->trans->t('Error downloading file, you probably have insufficient permissions'),
|
||||
'error.general' => $this->trans->t('An error occurred'),
|
||||
|
||||
// js/app/controllers/edit_credential.js
|
||||
'invalid.qr' => $this->trans->t('Invalid QR code'),
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
try {
|
||||
if (!_credential.shared_key) {
|
||||
_credential = CredentialService.decryptCredential(angular.copy(_credential));
|
||||
|
||||
} else {
|
||||
var enc_key = EncryptService.decryptString(_credential.shared_key);
|
||||
_credential = ShareService.decryptSharedCredential(angular.copy(_credential), enc_key);
|
||||
|
@ -261,54 +260,62 @@
|
|||
};
|
||||
|
||||
var notification;
|
||||
$scope.deleteCredential = function (credential) {
|
||||
var _credential = angular.copy(credential);
|
||||
try {
|
||||
_credential = CredentialService.decryptCredential(_credential);
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
$scope.deleteCredential = function (decrypted_credential) {
|
||||
let _credential = angular.copy(decrypted_credential);
|
||||
_credential.delete_time = new Date().getTime() / 1000;
|
||||
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
if ($scope.active_vault.credentials[i].credential_id === credential.credential_id) {
|
||||
$scope.active_vault.credentials[i].delete_time = _credential.delete_time;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.closeSelected();
|
||||
if (notification) {
|
||||
NotificationService.hideNotification(notification);
|
||||
}
|
||||
var key = CredentialService.getSharedKeyFromCredential(_credential);
|
||||
CredentialService.updateCredential(_credential, false, key).then(function () {
|
||||
|
||||
const key = CredentialService.getSharedKeyFromCredential(_credential);
|
||||
CredentialService.updateCredential(_credential, false, key).then(function (response) {
|
||||
decrypted_credential.delete_time = _credential.delete_time;
|
||||
for (let i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
if ($scope.active_vault.credentials[i].credential_id === _credential.credential_id) {
|
||||
$scope.active_vault.credentials[i].delete_time = _credential.delete_time;
|
||||
}
|
||||
}
|
||||
notification = NotificationService.showNotification($translate.instant('credential.deleted'), 5000);
|
||||
}, function (error) {
|
||||
if (error.data.msg) {
|
||||
NotificationService.showNotification(error.data.msg, 5000);
|
||||
} else {
|
||||
NotificationService.showNotification($translate.instant('error.general'), 5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.recoverCredential = function (credential) {
|
||||
var _credential = angular.copy(credential);
|
||||
try {
|
||||
_credential = CredentialService.decryptCredential(_credential);
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
if ($scope.active_vault.credentials[i].credential_id === credential.credential_id) {
|
||||
$scope.active_vault.credentials[i].delete_time = 0;
|
||||
}
|
||||
}
|
||||
$scope.recoverCredential = function (decrypted_credential) {
|
||||
let _credential = angular.copy(decrypted_credential);
|
||||
_credential.delete_time = 0;
|
||||
|
||||
$scope.closeSelected();
|
||||
if (notification) {
|
||||
NotificationService.hideNotification(notification);
|
||||
}
|
||||
var key = CredentialService.getSharedKeyFromCredential(_credential);
|
||||
CredentialService.updateCredential(_credential, false, key).then(function () {
|
||||
|
||||
const key = CredentialService.getSharedKeyFromCredential(_credential);
|
||||
CredentialService.updateCredential(_credential, false, key).then(function (response) {
|
||||
decrypted_credential.delete_time = 0;
|
||||
for (let i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
if ($scope.active_vault.credentials[i].credential_id === _credential.credential_id) {
|
||||
$scope.active_vault.credentials[i].delete_time = 0;
|
||||
}
|
||||
}
|
||||
NotificationService.showNotification($translate.instant('credential.recovered'), 5000);
|
||||
}, function (error) {
|
||||
if (error.data.msg) {
|
||||
NotificationService.showNotification(error.data.msg, 5000);
|
||||
} else {
|
||||
NotificationService.showNotification($translate.instant('error.general'), 5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.destroyCredential = function (credential) {
|
||||
var _credential = angular.copy(credential);
|
||||
const _credential = angular.copy(credential);
|
||||
CredentialService.destroyCredential(_credential.guid).then(function () {
|
||||
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
|
||||
if ($scope.active_vault.credentials[i].credential_id === credential.credential_id) {
|
||||
|
@ -317,6 +324,12 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
}, function (error) {
|
||||
if (error.data.msg) {
|
||||
NotificationService.showNotification(error.data.msg, 5000);
|
||||
} else {
|
||||
NotificationService.showNotification($translate.instant('error.general'), 5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
var key_strengths = [
|
||||
const key_strengths = [
|
||||
'password.poor',
|
||||
'password.poor',
|
||||
'password.weak',
|
||||
|
@ -86,7 +86,7 @@
|
|||
$scope.required_score = {'strength': translation};
|
||||
});
|
||||
|
||||
var btn_txt = $translate.instant('bookmarklet.text');
|
||||
const btn_txt = $translate.instant('bookmarklet.text');
|
||||
var http = location.protocol, slashes = http.concat("//"),
|
||||
host = slashes.concat(window.location.hostname + ":" + window.location.port),
|
||||
complete = host + location.pathname;
|
||||
|
@ -94,7 +94,7 @@
|
|||
|
||||
|
||||
$scope.saveVaultSettings = function () {
|
||||
var _vault = $scope.active_vault;
|
||||
let _vault = $scope.active_vault;
|
||||
_vault.name = $scope.new_vault_name;
|
||||
_vault.vault_settings = angular.copy($scope.vault_settings);
|
||||
VaultService.updateVault(_vault).then(function () {
|
||||
|
@ -236,8 +236,8 @@
|
|||
done: 0,
|
||||
total: _selected_credentials.length
|
||||
};
|
||||
var changeCredential = function (index, oldVaultPass, newVaultPass) {
|
||||
var usedKey = oldVaultPass;
|
||||
const changeCredential = function (index, oldVaultPass, newVaultPass) {
|
||||
let usedKey = oldVaultPass;
|
||||
|
||||
if (_selected_credentials[index].hasOwnProperty('shared_key')) {
|
||||
if (_selected_credentials[index].shared_key) {
|
||||
|
@ -267,7 +267,6 @@
|
|||
});
|
||||
};
|
||||
changeCredential(0, VaultService.getActiveVault().vaultKey, newVaultPass);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@
|
|||
this.call_progress(new progress_datatype(this.current, this.total, 'files'));
|
||||
|
||||
FileService.updateFile(fileData, this.parent.new_password).then((function () {
|
||||
// increase due to successful re-encryption / update / upload
|
||||
// increase due to successful re-encryption / update / upload
|
||||
this.current++;
|
||||
this.call_progress(new progress_datatype(this.current, this.total, 'files'));
|
||||
if (this.current === this.total) {
|
||||
|
|
Loading…
Add table
Reference in a new issue