Partialfix for #486 THIS DOES NOT CLOSE IT! v2

This commit is contained in:
fnuesse 2018-10-29 09:20:07 +01:00
parent ea01990672
commit 7694c291b7
No known key found for this signature in database
GPG key ID: 2089A3431243E819

View file

@ -32,8 +32,8 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate',
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate) {
.controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate', '$rootScope',
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate, $rootScope) {
$scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
@ -292,7 +292,7 @@
};
$scope.saving = false;
$scope.saveCredential = function () {
$scope.saving = true;
$scope.saving = true;
if ($scope.new_custom_field.label && $scope.new_custom_field.value) {
@ -301,8 +301,8 @@
if ($scope.storedCredential.password !== $scope.storedCredential.password_repeat){
$scope.saving = false;
NotificationService.showNotification($translate.instant('password.do.not.match'), 5000);
$scope.saving = false;
NotificationService.showNotification($translate.instant('password.do.not.match'), 5000);
return;
}
@ -313,7 +313,7 @@
if (!$scope.storedCredential.credential_id) {
$scope.storedCredential.vault_id = $scope.active_vault.vault_id;
CredentialService.createCredential($scope.storedCredential).then(function () {
$scope.saving = false;
$scope.saving = false;
$location.path('/vault/' + $routeParams.vault_id);
NotificationService.showNotification($translate.instant('credential.created'), 5000);
@ -345,14 +345,26 @@
_credential.description = _credential.description.replace(regex, "");
}
CredentialService.updateCredential(_credential, _useKey).then(function () {
$scope.saving = false;
$scope.saving = false;
SettingsService.setSetting('edit_credential', null);
$location.path('/vault/' + $routeParams.vault_id);
NotificationService.showNotification($translate.instant('credential.updated'), 5000);
});
}
$scope.refreshListWithSaved();
};
};
$scope.refreshListWithSaved = function () {
var current_vault = $rootScope.vaultCache[$scope.active_vault.guid];
var cv_credentials = current_vault.credentials;
for (var i = 0; i < cv_credentials.length; i++) {
if (cv_credentials[i].credential_id === $scope.storedCredential.credential_id) {
cv_credentials[i] = $scope.storedCredential;
}
}
current_vault.credentials=cv_credentials;
$rootScope.vaultCache[$scope.active_vault.guid] = current_vault;
};
$scope.cancel = function () {
$location.path('/vault/' + $routeParams.vault_id);