diff options
author | brantje <brantje@gmail.com> | 2016-09-14 22:12:10 +0300 |
---|---|---|
committer | brantje <brantje@gmail.com> | 2016-09-14 22:12:10 +0300 |
commit | dee5ecda55636d889a7db6bf2dfee6b64ba1ca2a (patch) | |
tree | 5eda85af12fab6ceab30881b7e280c5dabe60d8d /js/app/services/credentialservice.js | |
parent | 6caf31a9927fd5e335dc27dd90e573a3b285dc08 (diff) |
Start with showing Credentials
Diffstat (limited to 'js/app/services/credentialservice.js')
-rw-r--r-- | js/app/services/credentialservice.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/js/app/services/credentialservice.js b/js/app/services/credentialservice.js index 96892493..fa7e73bc 100644 --- a/js/app/services/credentialservice.js +++ b/js/app/services/credentialservice.js @@ -24,28 +24,31 @@ angular.module('passmanApp') 'url': null, 'favicon': null, 'renew_interval': null, - 'expire_time': null, + 'expire_time': 0, 'delete_time': 0, 'files': [], 'custom_fields': [], 'otp': {}, 'hidden': false }; - var _encryptedFields = ['description','username','password','files','custom_fields','otp']; + var _encryptedFields = ['description', 'username', 'password', 'files', 'custom_fields', 'otp', 'email', 'tags', 'url']; + + return { newCredential: function () { return angular.copy(credential); }, createCredential: function (credential) { - for(var i = 0; i < _encryptedFields.length; i++){ + var _credential = angular.copy(credential); + for (var i = 0; i < _encryptedFields.length; i++) { var field = _encryptedFields[i]; var fieldValue = angular.copy(credential[field]); - credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue)); + _credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue)); } var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials'); - return $http.post(queryUrl, credential).then(function (response) { - if(response.data){ + return $http.post(queryUrl, _credential).then(function (response) { + if (response.data) { return response.data; } else { return response; @@ -53,15 +56,16 @@ angular.module('passmanApp') }); }, updateCredential: function (credential) { - for(var i = 0; i < _encryptedFields.length; i++){ + var _credential = angular.copy(credential); + for (var i = 0; i < _encryptedFields.length; i++) { var field = _encryptedFields[i]; var fieldValue = angular.copy(credential[field]); - credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue)); + _credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue)); } - var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/'+ credential.credential_id); - return $http.post(queryUrl, credential).then(function (response) { - if(response.data){ + var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + credential.credential_id); + return $http.patch(queryUrl, _credential).then(function (response) { + if (response.data) { return response.data; } else { return response; @@ -69,7 +73,7 @@ angular.module('passmanApp') }); }, encryptCredential: function (credential) { - for(var i = 0; i < _encryptedFields.length; i++){ + for (var i = 0; i < _encryptedFields.length; i++) { var field = _encryptedFields[i]; var fieldValue = angular.copy(credential[field]); credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue)); @@ -77,7 +81,7 @@ angular.module('passmanApp') return credential; }, decryptCredential: function (credential) { - for(var i = 0; i < _encryptedFields.length; i++){ + for (var i = 0; i < _encryptedFields.length; i++) { var field = _encryptedFields[i]; var fieldValue = angular.copy(credential[field]); credential[field] = JSON.parse(EncryptService.decryptString(fieldValue)); |