diff --git a/appinfo/database.xml b/appinfo/database.xml
index 6901f66b..8837da82 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -37,7 +37,7 @@
true
- settings
+ vault_settings
clob
false
diff --git a/appinfo/info.xml b/appinfo/info.xml
index bcd27f37..bf63a5a1 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,7 +5,7 @@
A password manager for Nextcloud
AGPL
Sander Brand
- 1.0.2.10
+ 1.0.2.11
Passman
other
https://github.com/nextcloud/passman/
diff --git a/controller/vaultcontroller.php b/controller/vaultcontroller.php
index bccbf1c2..d6009b18 100644
--- a/controller/vaultcontroller.php
+++ b/controller/vaultcontroller.php
@@ -67,7 +67,7 @@ class VaultController extends ApiController {
'private_sharing_key' => $vault->getPrivateSharingKey(),
'public_sharing_key' => $vault->getPublicSharingKey(),
'sharing_keys_generated' => $vault->getSharingKeysGenerated(),
- 'settings' => $vault->getSettings(),
+ 'vault_settings' => $vault->getVaultSettings(),
'last_access' => $vault->getlastAccess()
);
$result['credentials'] = $credentials;
@@ -81,9 +81,15 @@ class VaultController extends ApiController {
/**
* @NoAdminRequired
*/
- public function update($vault_id) {
- $this->vaultService->getById($vault_id, $this->userId);
-
+ public function update($vault_id, $name, $vault_settings) {
+ $vault = array_pop($this->vaultService->getById($vault_id, $this->userId));
+ if($name) {
+ $vault->setName($name);
+ }
+ if($vault_settings) {
+ $vault->setVaultSettings($vault_settings);
+ }
+ $this->vaultService->updateVault($vault);
}
/**
diff --git a/js/app/controllers/settings.js b/js/app/controllers/settings.js
index b6d0924b..848d612f 100644
--- a/js/app/controllers/settings.js
+++ b/js/app/controllers/settings.js
@@ -8,9 +8,51 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
- .controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http',
- function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http) {
- $scope.active_vault = VaultService.getActiveVault();
+ .controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http', 'EncryptService',
+ function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http, EncryptService) {
+
+ if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
+ if (!$scope.active_vault) {
+ $location.path('/')
+ }
+ } else {
+ if (SettingsService.getSetting('defaultVault') && SettingsService.getSetting('defaultVaultPass')) {
+ var _vault = angular.copy(SettingsService.getSetting('defaultVault'));
+ VaultService.setActiveVault(_vault);
+ $scope.active_vault = _vault;
+
+ }
+ }
+
+ var _settings = {
+ pwSettings: {
+ 'length': 12,
+ 'useUppercase': true,
+ 'useLowercase': true,
+ 'useDigits': true,
+ 'useSpecialChars': true,
+ 'minimumDigitCount': 3,
+ 'avoidAmbiguousCharacters': false,
+ 'requireEveryCharType': true
+ }
+ };
+
+ $scope.vault_settings = angular.merge(_settings, $scope.active_vault.vault_settings);
+ console.log($scope.vault_settings);
+
+
+ $scope.saveVaultSettings = function () {
+ var _vault = $scope.active_vault;
+ _vault.vault_settings = angular.copy($scope.vault_settings);
+ _vault.vault_settings = window.btoa(JSON.stringify(_vault.vault_settings));
+ VaultService.updateVault(_vault).then(function () {
+ console.log('done');
+ });
+ };
+
+
+
+
$scope.tabs = [
{
title: 'General settings',
@@ -20,6 +62,11 @@ angular.module('passmanApp')
title: 'Password Audit',
url: 'views/partials/forms/settings/tool.html'
+ },
+ {
+ title: 'Password settings',
+ url: 'views/partials/forms/settings/password_settings.html'
+
},
{
title: 'Import credentials',
@@ -33,7 +80,7 @@ angular.module('passmanApp')
},
{
title: 'Sharing',
- url:'views/partials/forms/settings/sharing.html'
+ url: 'views/partials/forms/settings/sharing.html'
}
];
@@ -58,7 +105,7 @@ angular.module('passmanApp')
$scope.$watch(function () {
return VaultService.getActiveVault()
}, function (vault) {
- if(vault) {
+ if (vault) {
$scope.active_vault = vault;
}
});
@@ -108,7 +155,6 @@ angular.module('passmanApp')
$scope.cancel = function () {
$location.path('/vault/' + $routeParams.vault_id);
-
};
}]);
diff --git a/js/app/services/encryptservice.js b/js/app/services/encryptservice.js
index 4c67cec9..2b35ec0d 100644
--- a/js/app/services/encryptservice.js
+++ b/js/app/services/encryptservice.js
@@ -34,6 +34,7 @@ angular.module('passmanApp')
} catch(e) {
throw e;
}
- }
+ },
+
}
}]);
diff --git a/js/app/services/vaultservice.js b/js/app/services/vaultservice.js
index 284c69e9..6d61fc65 100644
--- a/js/app/services/vaultservice.js
+++ b/js/app/services/vaultservice.js
@@ -42,6 +42,9 @@ angular.module('passmanApp')
var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.vault_id);
return $http.get(queryUrl).then(function (response) {
if(response.data){
+ if(response.data.vault_settings){
+ response.data.vault_settings = JSON.parse(window.atob(response.data.vault_settings))
+ }
return response.data;
} else {
return response;
@@ -53,8 +56,8 @@ angular.module('passmanApp')
delete vault.defaultVaultPass;
delete vault.defaultVault;
- var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.vault_id);
- return $http.patch(queryUrl).then(function (response) {
+ var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + _vault.vault_id);
+ return $http.patch(queryUrl, _vault).then(function (response) {
if(response.data){
return response.data;
} else {
diff --git a/js/templates.js b/js/templates.js
index f68ffa77..30759abf 100644
--- a/js/templates.js
+++ b/js/templates.js
@@ -63,7 +63,7 @@ angular.module('views/partials/forms/settings/import.html', []).run(['$templateC
angular.module('views/partials/forms/settings/password_settings.html', []).run(['$templateCache', function($templateCache) {
'use strict';
$templateCache.put('views/partials/forms/settings/password_settings.html',
- '
');
+ '');
}]);
angular.module('views/partials/forms/settings/sharing.html', []).run(['$templateCache', function($templateCache) {
diff --git a/lib/Db/Vault.php b/lib/Db/Vault.php
index ca312290..c840cdea 100644
--- a/lib/Db/Vault.php
+++ b/lib/Db/Vault.php
@@ -31,8 +31,8 @@ use \OCP\AppFramework\Db\Entity;
* @method string getPrivateSharingKey()
* @method void setSharingKeysGenerated(integer $value)
* @method integer getSharingKeysGenerated()
- * @method void setSettings(integer $value)
- * @method integer getSettings()
+ * @method void setVaultSettings(integer $value)
+ * @method integer getVaultSettings()
*/
@@ -48,7 +48,7 @@ class Vault extends Entity implements \JsonSerializable{
protected $publicSharingKey;
protected $privateSharingKey;
protected $sharingKeysGenerated;
- protected $settings;
+ protected $vaultSettings;
public function __construct() {
// add types in constructor
diff --git a/lib/Db/VaultMapper.php b/lib/Db/VaultMapper.php
index 0c7e3d6d..b804a054 100644
--- a/lib/Db/VaultMapper.php
+++ b/lib/Db/VaultMapper.php
@@ -58,6 +58,10 @@ class VaultMapper extends Mapper {
$this->update($vault);
}
+ public function updateVault(Vault $vault){
+ $this->update($vault);
+ }
+
public function updateSharingKeys($vault_id, $privateKey, $publicKey){
$vault = new Vault();
$vault->setId($vault_id);
diff --git a/lib/Service/VaultService.php b/lib/Service/VaultService.php
index d078674b..a8b365c4 100644
--- a/lib/Service/VaultService.php
+++ b/lib/Service/VaultService.php
@@ -31,25 +31,17 @@ class VaultService {
public function getById($vault_id, $user_id) {
$vault = $this->vaultMapper->find($vault_id, $user_id);
- $vault = $vault[0];
- $return = array(
- 'vault_id' => $vault->getId(),
- 'guid' => $vault->getGuid(),
- 'name' => $vault->getName(),
- 'created' => $vault->getCreated(),
- 'private_sharing_key' => $vault->getPrivateSharingKey(),
- 'public_sharing_key' => $vault->getPublicSharingKey(),
- 'sharing_keys_generated' => $vault->getSharingKeysGenerated(),
- 'settings' => $vault->getSettings(),
- 'last_access' => $vault->getlastAccess()
- );
- return $return;
+ return $vault;
}
public function createVault($vault_name, $userId) {
return $this->vaultMapper->create($vault_name, $userId);
}
+ public function updateVault($vault) {
+ return $this->vaultMapper->updateVault($vault);
+ }
+
public function setLastAccess($vault_id, $user_id){
return $this->vaultMapper->setLastAccess($vault_id, $user_id);
}
diff --git a/templates/views/partials/forms/settings/password_settings.html b/templates/views/partials/forms/settings/password_settings.html
new file mode 100644
index 00000000..c04e6529
--- /dev/null
+++ b/templates/views/partials/forms/settings/password_settings.html
@@ -0,0 +1,52 @@
+
+
\ No newline at end of file