diff --git a/src/app/services/cipherService.js b/src/app/services/cipherService.js index 5bb4f1822b..c7c1873456 100644 --- a/src/app/services/cipherService.js +++ b/src/app/services/cipherService.js @@ -414,7 +414,7 @@ angular var cipher = { id: unencryptedCipher.id, - 'type': type, + 'type': type || unencryptedCipher.type, organizationId: unencryptedCipher.organizationId || null, folderId: unencryptedCipher.folderId === '' ? null : unencryptedCipher.folderId, favorite: unencryptedCipher.favorite !== null ? unencryptedCipher.favorite : false, diff --git a/src/app/vault/vaultAddLoginController.js b/src/app/vault/vaultAddCipherController.js similarity index 53% rename from src/app/vault/vaultAddLoginController.js rename to src/app/vault/vaultAddCipherController.js index 75fdb38f83..a87dc8ce13 100644 --- a/src/app/vault/vaultAddLoginController.js +++ b/src/app/vault/vaultAddCipherController.js @@ -1,57 +1,70 @@ angular .module('bit.vault') - .controller('vaultAddLoginController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, - passwordService, selectedFolder, $analytics, checkedFavorite, $rootScope, authService, $uibModal) { - $analytics.eventTrack('vaultAddLoginController', { category: 'Modal' }); + .controller('vaultAddCipherController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, + passwordService, selectedFolder, $analytics, checkedFavorite, $rootScope, authService, $uibModal, constants) { + $analytics.eventTrack('vaultAddCipherController', { category: 'Modal' }); $scope.folders = $rootScope.vaultFolders; - $scope.login = { + $scope.constants = constants; + $scope.selectedType = constants.cipherType.login.toString(); + $scope.cipher = { folderId: selectedFolder ? selectedFolder.id : null, - favorite: checkedFavorite === true + favorite: checkedFavorite === true, + type: constants.cipherType.login, + card: { + brand: 'visa' + }, + secureNote: { + type: '0' + } }; authService.getUserProfile().then(function (profile) { $scope.useTotp = profile.premium; }); + $scope.typeChanged = function () { + $scope.cipher.type = parseInt($scope.selectedType); + }; + $scope.savePromise = null; - $scope.save = function (model) { - var login = cipherService.encryptLogin(model); - $scope.savePromise = apiService.ciphers.post(login, function (loginResponse) { - $analytics.eventTrack('Created Login'); - var decLogin = cipherService.decryptLogin(loginResponse); - $uibModalInstance.close(decLogin); + $scope.save = function () { + var cipher = cipherService.encryptCipher($scope.cipher); + $scope.savePromise = apiService.ciphers.post(cipher, function (cipherResponse) { + $analytics.eventTrack('Created Cipher'); + var decCipher = cipherService.decryptCipherPreview(cipherResponse); + $uibModalInstance.close(decCipher); }).$promise; }; $scope.generatePassword = function () { - if (!$scope.login.password || confirm('Are you sure you want to overwrite the current password?')) { + if (!$scope.cipher.login.password || confirm('Are you sure you want to overwrite the current password?')) { $analytics.eventTrack('Generated Password From Add'); - $scope.login.password = passwordService.generatePassword({ length: 12, special: true }); + $scope.cipher.login.password = passwordService.generatePassword({ length: 12, special: true }); } }; $scope.addField = function () { - if (!$scope.login.fields) { - $scope.login.fields = []; + if (!$scope.cipher.fields) { + $scope.cipher.fields = []; } - $scope.login.fields.push({ - type: '0', + $scope.cipher.fields.push({ + type: constants.fieldType.text.toString(), name: null, value: null }); }; $scope.removeField = function (field) { - var index = $scope.login.fields.indexOf(field); + var index = $scope.cipher.fields.indexOf(field); if (index > -1) { - $scope.login.fields.splice(index, 1); + $scope.cipher.fields.splice(index, 1); } }; $scope.toggleFavorite = function () { - $scope.login.favorite = !$scope.login.favorite; + $scope.cipher.favorite = !$scope.cipher.favorite; }; $scope.clipboardSuccess = function (e) { diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index d03b433bd9..06135fdfe9 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -175,8 +175,8 @@ $scope.addCipher = function (folder, favorite) { var addModel = $uibModal.open({ animation: true, - templateUrl: 'app/vault/views/vaultAddLogin.html', - controller: 'vaultAddLoginController', + templateUrl: 'app/vault/views/vaultAddCipher.html', + controller: 'vaultAddCipherController', resolve: { selectedFolder: function () { return folder; }, checkedFavorite: function () { return favorite; } diff --git a/src/app/vault/vaultEditCipherController.js b/src/app/vault/vaultEditCipherController.js index 9c5ebb55f3..0814603913 100644 --- a/src/app/vault/vaultEditCipherController.js +++ b/src/app/vault/vaultEditCipherController.js @@ -61,7 +61,7 @@ } $scope.cipher.fields.push({ - type: constants.fieldType.text, + type: constants.fieldType.text.toString(), name: null, value: null }); diff --git a/src/app/vault/views/vaultAddCipher.html b/src/app/vault/views/vaultAddCipher.html new file mode 100644 index 0000000000..6c735e3abd --- /dev/null +++ b/src/app/vault/views/vaultAddCipher.html @@ -0,0 +1,253 @@ + +
+ + +
diff --git a/src/app/vault/views/vaultAddLogin.html b/src/app/vault/views/vaultAddLogin.html deleted file mode 100644 index b747a8a790..0000000000 --- a/src/app/vault/views/vaultAddLogin.html +++ /dev/null @@ -1,171 +0,0 @@ - -
- - -
diff --git a/src/app/vault/views/vaultEditCipher.html b/src/app/vault/views/vaultEditCipher.html index 76d51bba94..750fdc73d3 100644 --- a/src/app/vault/views/vaultEditCipher.html +++ b/src/app/vault/views/vaultEditCipher.html @@ -32,7 +32,7 @@ -
+
@@ -112,14 +112,14 @@
-
+
- +
-
+
-
+
diff --git a/src/index.html b/src/index.html index db2ff45947..33c1b6c90e 100644 --- a/src/index.html +++ b/src/index.html @@ -211,7 +211,7 @@ - +