diff --git a/src/popup/app/vault/vaultAddCipherController.js b/src/popup/app/vault/vaultAddCipherController.js index 58377b90af..67ee1f9532 100644 --- a/src/popup/app/vault/vaultAddCipherController.js +++ b/src/popup/app/vault/vaultAddCipherController.js @@ -46,7 +46,7 @@ $scope.savePromise = null; $scope.save = function () { - if (!cipher.name || cipher.name === '') { + if (!$scope.cipher.name || $scope.cipher.name === '') { toastr.error(i18nService.nameRequired, i18nService.errorsOccurred); return; } diff --git a/src/popup/app/vault/vaultEditCipherController.js b/src/popup/app/vault/vaultEditCipherController.js index 1d6607fa7d..c4929ccc27 100644 --- a/src/popup/app/vault/vaultEditCipherController.js +++ b/src/popup/app/vault/vaultEditCipherController.js @@ -7,6 +7,7 @@ angular $scope.constants = constantsService; $scope.showAttachments = !utilsService.isEdge(); $scope.addFieldType = constantsService.fieldType.text.toString(); + $scope.selectedType = constantsService.cipherType.login.toString(); var cipherId = $stateParams.cipherId; var fromView = $stateParams.fromView; var from = $stateParams.from; @@ -34,14 +35,18 @@ angular utilsService.initListSectionItemListeners($(document), angular); + $scope.typeChanged = function () { + $scope.cipher.type = parseInt($scope.selectedType); + }; + $scope.savePromise = null; - $scope.save = function (model) { - if (!model.name) { + $scope.save = function () { + if (!$scope.cipher.name || $scope.cipher.name === '') { toastr.error(i18nService.nameRequired, i18nService.errorsOccurred); return; } - $scope.savePromise = loginService.encrypt(model).then(function (cipherModel) { + $scope.savePromise = loginService.encrypt($scope.cipher).then(function (cipherModel) { var cipher = new Cipher(cipherModel, true); return loginService.saveWithServer(cipher).then(function (c) { $analytics.eventTrack('Edited Cipher'); diff --git a/src/popup/app/vault/vaultViewCipherController.js b/src/popup/app/vault/vaultViewCipherController.js index 83bf22003f..e5486c75af 100644 --- a/src/popup/app/vault/vaultViewCipherController.js +++ b/src/popup/app/vault/vaultViewCipherController.js @@ -12,34 +12,38 @@ angular $scope.isPremium = tokenService.getPremium(); $scope.cipher = null; + var cipherObj = null; loginService.get($stateParams.cipherId).then(function (cipher) { if (!cipher) { return; } + cipherObj = cipher; return cipher.decrypt(); }).then(function (model) { $scope.cipher = model; - if (model.password) { - $scope.cipher.maskedPassword = $scope.maskValue(model.password); - } + if (model.type == constantsService.cipherType.login && model.login) { + if (model.login.password) { + $scope.cipher.maskedPassword = $scope.maskValue(model.login.password); + } - if (model.uri) { - $scope.cipher.showLaunch = model.uri.startsWith('http://') || model.uri.startsWith('https://'); - var domain = utilsService.getDomain(model.uri); - if (domain) { - $scope.cipher.website = domain; + if (model.login.uri) { + $scope.cipher.showLaunch = model.login.uri.startsWith('http://') || model.login.uri.startsWith('https://'); + var domain = utilsService.getDomain(model.login.uri); + if (domain) { + $scope.cipher.login.website = domain; + } + else { + $scope.cipher.login.website = model.login.uri; + } } else { - $scope.cipher.website = model.uri; + $scope.cipher.showLaunch = false; } } - else { - $scope.cipher.showLaunch = false; - } - if (model.totp && (cipher.organizationUseTotp || tokenService.getPremium())) { + if (model.login.totp && (cipherObj.organizationUseTotp || tokenService.getPremium())) { totpUpdateCode(); totpTick(); @@ -87,7 +91,7 @@ angular $scope.launchWebsite = function (cipher) { if (cipher.showLaunch) { $analytics.eventTrack('Launched Website'); - chrome.tabs.create({ url: cipher.uri }); + chrome.tabs.create({ url: cipher.login.uri }); } }; @@ -192,11 +196,11 @@ angular }); function totpUpdateCode() { - if (!$scope.cipher.totp) { + if ($scope.cipher.type !== constantsService.cipherType.login || !$scope.cipher.login.totp) { return; } - totpService.getCode($scope.cipher.totp).then(function (code) { + totpService.getCode($scope.cipher.login.totp).then(function (code) { $timeout(function () { if (code) { $scope.totpCodeFormatted = code.substring(0, 3) + ' ' + code.substring(3); diff --git a/src/popup/app/vault/views/vaultAddCipher.html b/src/popup/app/vault/views/vaultAddCipher.html index 7855abe5db..10e2d5e818 100644 --- a/src/popup/app/vault/views/vaultAddCipher.html +++ b/src/popup/app/vault/views/vaultAddCipher.html @@ -188,7 +188,7 @@