diff --git a/controller/vaultcontroller.php b/controller/vaultcontroller.php index d6009b18..191d1d9a 100644 --- a/controller/vaultcontroller.php +++ b/controller/vaultcontroller.php @@ -38,9 +38,26 @@ class VaultController extends ApiController { * @NoAdminRequired */ public function listVaults() { - + $result = array(); $vaults = $this->vaultService->getByUser($this->userId); - return new JSONResponse($vaults); + + $protected_credential_fields = array('getDescription','getEmail','getUsername','getPassword'); + + foreach($vaults as $vault){ + $credential = $this->credentialService->getRandomCredentialByVaultId($vault->getId(), $this->userId); + $secret_field = $protected_credential_fields[array_rand($protected_credential_fields)]; + array_push($result, array( + 'vault_id' => $vault->getId(), + 'guid' => $vault->getGuid(), + 'name' => $vault->getName(), + 'created' => $vault->getCreated(), + 'public_sharing_key' => $vault->getPublicSharingKey(), + 'last_access' => $vault->getlastAccess(), + 'challenge_password' => $credential->{$secret_field}() + )); + } + + return new JSONResponse($result); } /** diff --git a/js/app/controllers/settings.js b/js/app/controllers/settings.js index c0849854..5ceeff83 100644 --- a/js/app/controllers/settings.js +++ b/js/app/controllers/settings.js @@ -11,6 +11,7 @@ angular.module('passmanApp') .controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http', 'EncryptService','NotificationService', function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http, EncryptService, NotificationService) { $scope.vault_settings = {}; + $scope.new_vault_name = ''; $scope.active_vault = VaultService.getActiveVault(); if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { if (!$scope.active_vault) { @@ -35,7 +36,8 @@ angular.module('passmanApp') 'avoidAmbiguousCharacters': false, 'requireEveryCharType': true, 'generateOnCreate': true - }) + }); + $scope.new_vault_name = angular.copy($scope.active_vault.name); }) } } @@ -43,9 +45,11 @@ angular.module('passmanApp') $scope.saveVaultSettings = function () { var _vault = $scope.active_vault; + _vault.name = $scope.new_vault_name; _vault.vault_settings = angular.copy($scope.vault_settings); VaultService.updateVault(_vault).then(function () { VaultService.setActiveVault(_vault); + $scope.active_vault.name = angular.copy(_vault.name); NotificationService.showNotification('Settings saved', 5000); }); }; diff --git a/js/app/controllers/vault.js b/js/app/controllers/vault.js index 2959ce11..2f64271c 100644 --- a/js/app/controllers/vault.js +++ b/js/app/controllers/vault.js @@ -101,19 +101,17 @@ angular.module('passmanApp') _vault.vaultKey = angular.copy(vault_key); VaultService.setActiveVault(_vault); - VaultService.getVault(vault).then(function (vault) { - var credential = vault.credentials[0]; - try { - var c = CredentialService.decryptCredential(credential); - if ($scope.remember_vault_password) { - SettingsService.setSetting('defaultVaultPass', vault_key); - } - _loginToVault(vault, vault_key); - - } catch (e) { - $scope.error = 'Incorrect vault password!' + try { + var c = EncryptService.decryptString(vault.challenge_password); + if ($scope.remember_vault_password) { + SettingsService.setSetting('defaultVaultPass', vault_key); } - }) + _loginToVault(vault, vault_key); + + } catch (e) { + $scope.error = 'Incorrect vault password!' + } + }; diff --git a/js/app/services/vaultservice.js b/js/app/services/vaultservice.js index aa1408b3..37e7e772 100644 --- a/js/app/services/vaultservice.js +++ b/js/app/services/vaultservice.js @@ -73,8 +73,9 @@ angular.module('passmanApp') }, updateVault: function (vault) { var _vault = angular.copy(vault); - delete vault.defaultVaultPass; - delete vault.defaultVault; + delete _vault.defaultVaultPass; + delete _vault.defaultVault; + delete _vault.vaultKey; _vault.vault_settings = window.btoa(JSON.stringify(_vault.vault_settings)) var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + _vault.vault_id); return $http.patch(queryUrl, _vault).then(function (response) { diff --git a/js/templates.js b/js/templates.js index d541fb44..9b9d4f0b 100644 --- a/js/templates.js +++ b/js/templates.js @@ -51,7 +51,7 @@ angular.module('views/partials/forms/settings/export.html', []).run(['$templateC angular.module('views/partials/forms/settings/general_settings.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/partials/forms/settings/general_settings.html', - '
Version: {{passman_version}}
Bla bla about passman, changelog.
Donate to support development
Version: {{passman_version}}
Bla bla about passman, changelog.
Donate to support development