From 0fc9f498df0181bec8e18f27e589d9a4c5afcbed Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 14 Oct 2017 16:55:47 -0400 Subject: [PATCH] more login to cipher renames --- src/popup/app/config.js | 28 +++++------ src/popup/app/current/currentController.js | 30 +++++------ src/popup/app/current/views/current.html | 30 +++++------ ...troller.js => vaultAddCipherController.js} | 30 +++++------ src/popup/app/vault/vaultController.js | 6 +-- ...roller.js => vaultEditCipherController.js} | 50 +++++++++---------- ...roller.js => vaultViewCipherController.js} | 44 ++++++++-------- .../app/vault/vaultViewFolderController.js | 2 +- ...vaultAddLogin.html => vaultAddCipher.html} | 0 ...ultEditLogin.html => vaultEditCipher.html} | 22 ++++---- ...ultViewLogin.html => vaultViewCipher.html} | 42 ++++++++-------- src/popup/index.html | 6 +-- 12 files changed, 145 insertions(+), 145 deletions(-) rename src/popup/app/vault/{vaultAddLoginController.js => vaultAddCipherController.js} (72%) rename src/popup/app/vault/{vaultEditLoginController.js => vaultEditCipherController.js} (74%) rename src/popup/app/vault/{vaultViewLoginController.js => vaultViewCipherController.js} (83%) rename src/popup/app/vault/views/{vaultAddLogin.html => vaultAddCipher.html} (100%) rename src/popup/app/vault/views/{vaultEditLogin.html => vaultEditCipher.html} (92%) rename src/popup/app/vault/views/{vaultViewLogin.html => vaultViewCipher.html} (83%) diff --git a/src/popup/app/config.js b/src/popup/app/config.js index 611ffed5..cf69c05f 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -134,26 +134,26 @@ data: { authorize: true }, params: { animation: null, from: 'vault' } }) - .state('viewLogin', { - url: '/view-login?loginId', - templateUrl: 'app/vault/views/vaultViewLogin.html', - controller: 'vaultViewLoginController', + .state('viewCipher', { + url: '/view-cipher?cipherId', + templateUrl: 'app/vault/views/vaultViewCipher.html', + controller: 'vaultViewCipherController', data: { authorize: true }, params: { animation: null, from: 'vault' } }) - .state('addLogin', { - url: '/add-login', - templateUrl: 'app/vault/views/vaultAddLogin.html', - controller: 'vaultAddLoginController', + .state('addCipher', { + url: '/add-cipher', + templateUrl: 'app/vault/views/vaultAddCipher.html', + controller: 'vaultAddCipherController', data: { authorize: true }, - params: { animation: null, name: null, uri: null, folderId: null, login: null, from: 'vault' } + params: { animation: null, name: null, uri: null, folderId: null, cipher: null, from: 'vault' } }) - .state('editLogin', { - url: '/edit-login?loginId', - templateUrl: 'app/vault/views/vaultEditLogin.html', - controller: 'vaultEditLoginController', + .state('editCipher', { + url: '/edit-cipher?cipherId', + templateUrl: 'app/vault/views/vaultEditCipher.html', + controller: 'vaultEditCipherController', data: { authorize: true }, - params: { animation: null, fromView: true, login: null, from: 'vault' } + params: { animation: null, fromView: true, cipher: null, from: 'vault' } }) .state('attachments', { url: '/attachments?id', diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index 6786e344..056f5444 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -1,7 +1,7 @@ angular .module('bit.current') - .controller('currentController', function ($scope, loginService, utilsService, toastr, $q, $window, $state, $timeout, + .controller('currentController', function ($scope, loginService, utilsService, toastr, $window, $state, $timeout, autofillService, $analytics, i18nService, totpService, tokenService) { $scope.i18n = i18nService; @@ -10,7 +10,7 @@ angular domain = null, canAutofill = false; - $scope.logins = []; + $scope.ciphers = []; $scope.loaded = false; $scope.searchText = null; $('#search').focus(); @@ -42,9 +42,9 @@ angular canAutofill = true; }); - $q.when(loginService.getAllDecryptedForDomain(domain)).then(function (logins) { + loginService.getAllDecryptedForDomain(domain).then(function (logins) { $scope.loaded = true; - $scope.logins = logins; + $scope.ciphers = ciphers; }); }); } @@ -59,8 +59,8 @@ angular $analytics.eventTrack('Copied ' + (type === i18nService.username ? 'Username' : 'Password')); }; - $scope.addLogin = function () { - $state.go('addLogin', { + $scope.addCipher = function () { + $state.go('addCipher', { animation: 'in-slide-up', name: domain, uri: url, @@ -68,14 +68,14 @@ angular }); }; - $scope.fillLogin = function (login) { + $scope.fillCipher = function (cipher) { if (!canAutofill) { $analytics.eventTrack('Autofilled Error'); toastr.error(i18nService.autofillError); } autofillService.doAutoFill({ - login: login, + cipher: cipher, pageDetails: pageDetails, fromBackground: false }).then(function (totpCode) { @@ -92,21 +92,21 @@ angular }); }; - $scope.viewLogin = function (login) { - $state.go('viewLogin', { - loginId: login.id, + $scope.viewCipher = function (cipher) { + $state.go('viewCipher', { + cipherId: cipher.id, animation: 'in-slide-up', from: 'current' }); }; - $scope.sortUriMatch = function (login) { + $scope.sortUriMatch = function (cipher) { // exact matches should sort earlier. - return url && url.startsWith(login.uri) ? 0 : 1; + return url && url.startsWith(cipher.uri) ? 0 : 1; }; - $scope.sortLastUsed = function (login) { - return login.localData && login.localData.lastUsedDate ? -1 * login.localData.lastUsedDate : 0; + $scope.sortLastUsed = function (cipher) { + return cipher.localData && cipher.localData.lastUsedDate ? -1 * cipher.localData.lastUsedDate : 0; }; $scope.searchVault = function () { diff --git a/src/popup/app/current/views/current.html b/src/popup/app/current/views/current.html index 62d7e190..efd27154 100644 --- a/src/popup/app/current/views/current.html +++ b/src/popup/app/current/views/current.html @@ -10,47 +10,47 @@
- +
-
+
-
+

{{i18n.autoFillInfo}} - +

diff --git a/src/popup/app/vault/vaultAddLoginController.js b/src/popup/app/vault/vaultAddCipherController.js similarity index 72% rename from src/popup/app/vault/vaultAddLoginController.js rename to src/popup/app/vault/vaultAddCipherController.js index e239fe0b..32fc95fb 100644 --- a/src/popup/app/vault/vaultAddLoginController.js +++ b/src/popup/app/vault/vaultAddCipherController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultAddLoginController', function ($scope, $state, $stateParams, loginService, folderService, + .controller('vaultAddCipherController', function ($scope, $state, $stateParams, loginService, folderService, cryptoService, $q, toastr, utilsService, $analytics, i18nService, constantsService) { $scope.i18n = i18nService; $scope.constants = constantsService; @@ -9,17 +9,17 @@ var from = $stateParams.from, folderId = $stateParams.folderId; - $scope.login = { + $scope.cipher = { folderId: folderId, name: $stateParams.name, uri: $stateParams.uri }; - if ($stateParams.login) { - angular.extend($scope.login, $stateParams.login); + if ($stateParams.cipher) { + angular.extend($scope.cipher, $stateParams.cipher); } - if (!$stateParams.login && $scope.login.name && $scope.login.uri) { + if (!$stateParams.cipher && $scope.cipher.name && $scope.cipher.uri) { $('#username').focus(); } else { @@ -38,10 +38,10 @@ return; } - $scope.savePromise = $q.when(loginService.encrypt(model)).then(function (loginModel) { - var login = new Login(loginModel, true); - return $q.when(loginService.saveWithServer(login)).then(function (login) { - $analytics.eventTrack('Added Login'); + $scope.savePromise = loginService.encrypt(model).then(function (cipherModel) { + var cipher = new Cipher(cipherModel, true); + return loginService.saveWithServer(cipher).then(function (c) { + $analytics.eventTrack('Added Cipher'); toastr.success(i18nService.addedLogin); $scope.close(); }); @@ -68,11 +68,11 @@ }; $scope.addField = function (type) { - if (!$scope.login.fields) { - $scope.login.fields = []; + if (!$scope.cipher.fields) { + $scope.cipher.fields = []; } - $scope.login.fields.push({ + $scope.cipher.fields.push({ type: parseInt(type), name: null, value: null @@ -80,9 +80,9 @@ }; $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); } }; @@ -92,7 +92,7 @@ animation: 'in-slide-up', addState: { from: from, - login: $scope.login + cipher: $scope.cipher } }); }; diff --git a/src/popup/app/vault/vaultController.js b/src/popup/app/vault/vaultController.js index ea5a7b3a..bbc63d5c 100644 --- a/src/popup/app/vault/vaultController.js +++ b/src/popup/app/vault/vaultController.js @@ -118,7 +118,7 @@ $scope.addCipher = function () { storeState(); - $state.go('addLogin', { + $state.go('addCipher', { animation: 'in-slide-up', from: 'vault' }); @@ -141,8 +141,8 @@ } storeState(); - $state.go('viewLogin', { - loginId: cipher.id, + $state.go('viewCipher', { + cipherId: cipher.id, animation: 'in-slide-up', from: 'vault' }); diff --git a/src/popup/app/vault/vaultEditLoginController.js b/src/popup/app/vault/vaultEditCipherController.js similarity index 74% rename from src/popup/app/vault/vaultEditLoginController.js rename to src/popup/app/vault/vaultEditCipherController.js index 18d143a5..1d6607fa 100644 --- a/src/popup/app/vault/vaultEditLoginController.js +++ b/src/popup/app/vault/vaultEditCipherController.js @@ -1,30 +1,30 @@ angular .module('bit.vault') - .controller('vaultEditLoginController', function ($scope, $state, $stateParams, loginService, folderService, + .controller('vaultEditCipherController', function ($scope, $state, $stateParams, loginService, folderService, cryptoService, toastr, SweetAlert, utilsService, $analytics, i18nService, constantsService) { $scope.i18n = i18nService; $scope.constants = constantsService; $scope.showAttachments = !utilsService.isEdge(); $scope.addFieldType = constantsService.fieldType.text.toString(); - var loginId = $stateParams.loginId; + var cipherId = $stateParams.cipherId; var fromView = $stateParams.fromView; var from = $stateParams.from; - $scope.login = { + $scope.cipher = { folderId: null }; $('#name').focus(); - if ($stateParams.login) { - angular.extend($scope.login, $stateParams.login); + if ($stateParams.cipher) { + angular.extend($scope.cipher, $stateParams.cipher); } else { - loginService.get(loginId).then(function (login) { - return login.decrypt(); + loginService.get(cipherId).then(function (cipher) { + return cipher.decrypt(); }).then(function (model) { - $scope.login = model; + $scope.cipher = model; }); } @@ -41,10 +41,10 @@ angular return; } - $scope.savePromise = loginService.encrypt(model).then(function (loginModel) { - var login = new Login(loginModel, true); - return loginService.saveWithServer(login).then(function (login) { - $analytics.eventTrack('Edited Login'); + $scope.savePromise = loginService.encrypt(model).then(function (cipherModel) { + var cipher = new Cipher(cipherModel, true); + return loginService.saveWithServer(cipher).then(function (c) { + $analytics.eventTrack('Edited Cipher'); toastr.success(i18nService.editedLogin); $scope.close(); }); @@ -60,8 +60,8 @@ angular cancelButtonText: i18nService.no }, function (confirmed) { if (confirmed) { - loginService.deleteWithServer(loginId).then(function () { - $analytics.eventTrack('Deleted Login'); + loginService.deleteWithServer(cipherId).then(function () { + $analytics.eventTrack('Deleted Cipher'); toastr.success(i18nService.deletedLogin); $state.go('tabs.vault', { animation: 'out-slide-down' @@ -73,7 +73,7 @@ angular $scope.attachments = function () { $state.go('attachments', { - id: loginId, + id: cipherId, animation: 'in-slide-up', from: from, fromView: fromView @@ -82,8 +82,8 @@ angular $scope.close = function () { if (fromView) { - $state.go('viewLogin', { - loginId: loginId, + $state.go('viewCipher', { + cipherId: cipherId, animation: 'out-slide-down', from: from }); @@ -96,11 +96,11 @@ angular }; $scope.addField = function (type) { - if (!$scope.login.fields) { - $scope.login.fields = []; + if (!$scope.cipher.fields) { + $scope.cipher.fields = []; } - $scope.login.fields.push({ + $scope.cipher.fields.push({ type: parseInt(type), name: null, value: null @@ -108,14 +108,14 @@ angular }; $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.generatePassword = function () { - if ($scope.login.password) { + if ($scope.cipher.password) { SweetAlert.swal({ title: i18nService.overwritePassword, text: i18nService.overwritePasswordConfirmation, @@ -140,8 +140,8 @@ angular animation: 'in-slide-up', editState: { fromView: fromView, - loginId: loginId, - login: $scope.login, + cipherId: cipherId, + cipher: $scope.cipher, from: from } }); diff --git a/src/popup/app/vault/vaultViewLoginController.js b/src/popup/app/vault/vaultViewCipherController.js similarity index 83% rename from src/popup/app/vault/vaultViewLoginController.js rename to src/popup/app/vault/vaultViewCipherController.js index 21551268..83bf2200 100644 --- a/src/popup/app/vault/vaultViewLoginController.js +++ b/src/popup/app/vault/vaultViewCipherController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultViewLoginController', function ($scope, $state, $stateParams, loginService, toastr, + .controller('vaultViewCipherController', function ($scope, $state, $stateParams, loginService, toastr, $analytics, i18nService, utilsService, totpService, $timeout, tokenService, $window, cryptoService, SweetAlert, constantsService) { $scope.constants = constantsService; @@ -11,35 +11,35 @@ angular totpInterval = null; $scope.isPremium = tokenService.getPremium(); - $scope.login = null; - loginService.get($stateParams.loginId).then(function (login) { - if (!login) { + $scope.cipher = null; + loginService.get($stateParams.cipherId).then(function (cipher) { + if (!cipher) { return; } - return login.decrypt(); + return cipher.decrypt(); }).then(function (model) { - $scope.login = model; + $scope.cipher = model; if (model.password) { - $scope.login.maskedPassword = $scope.maskValue(model.password); + $scope.cipher.maskedPassword = $scope.maskValue(model.password); } if (model.uri) { - $scope.login.showLaunch = model.uri.startsWith('http://') || model.uri.startsWith('https://'); + $scope.cipher.showLaunch = model.uri.startsWith('http://') || model.uri.startsWith('https://'); var domain = utilsService.getDomain(model.uri); if (domain) { - $scope.login.website = domain; + $scope.cipher.website = domain; } else { - $scope.login.website = model.uri; + $scope.cipher.website = model.uri; } } else { - $scope.login.showLaunch = false; + $scope.cipher.showLaunch = false; } - if (model.totp && (login.organizationUseTotp || tokenService.getPremium())) { + if (model.totp && (cipher.organizationUseTotp || tokenService.getPremium())) { totpUpdateCode(); totpTick(); @@ -53,10 +53,10 @@ angular } }); - $scope.edit = function (login) { - $state.go('editLogin', { + $scope.edit = function (cipher) { + $state.go('editCipher', { animation: 'in-slide-up', - loginId: login.id, + cipherId: cipher.id, fromView: true, from: from }); @@ -84,10 +84,10 @@ angular } }; - $scope.launchWebsite = function (login) { - if (login.showLaunch) { + $scope.launchWebsite = function (cipher) { + if (cipher.showLaunch) { $analytics.eventTrack('Launched Website'); - chrome.tabs.create({ url: login.uri }); + chrome.tabs.create({ url: cipher.uri }); } }; @@ -120,7 +120,7 @@ angular }; $scope.download = function (attachment) { - if (!$scope.login.organizationId && !tokenService.getPremium()) { + if (!$scope.cipher.organizationId && !tokenService.getPremium()) { SweetAlert.swal({ title: i18nService.premiumRequired, text: i18nService.premiumRequiredDesc, @@ -152,7 +152,7 @@ angular return; } - cryptoService.getOrgKey($scope.login.organizationId).then(function (key) { + cryptoService.getOrgKey($scope.cipher.organizationId).then(function (key) { return cryptoService.decryptFromBytes(req.response, key); }).then(function (decBuf) { var blob = new Blob([decBuf]); @@ -192,11 +192,11 @@ angular }); function totpUpdateCode() { - if (!$scope.login.totp) { + if (!$scope.cipher.totp) { return; } - totpService.getCode($scope.login.totp).then(function (code) { + totpService.getCode($scope.cipher.totp).then(function (code) { $timeout(function () { if (code) { $scope.totpCodeFormatted = code.substring(0, 3) + ' ' + code.substring(3); diff --git a/src/popup/app/vault/vaultViewFolderController.js b/src/popup/app/vault/vaultViewFolderController.js index 34ea64f7..63690bf2 100644 --- a/src/popup/app/vault/vaultViewFolderController.js +++ b/src/popup/app/vault/vaultViewFolderController.js @@ -190,7 +190,7 @@ storeState(); $state.go('viewLogin', { - loginId: cipher.id, + cipherId: cipher.id, animation: 'in-slide-up', from: 'folder' }); diff --git a/src/popup/app/vault/views/vaultAddLogin.html b/src/popup/app/vault/views/vaultAddCipher.html similarity index 100% rename from src/popup/app/vault/views/vaultAddLogin.html rename to src/popup/app/vault/views/vaultAddCipher.html diff --git a/src/popup/app/vault/views/vaultEditLogin.html b/src/popup/app/vault/views/vaultEditCipher.html similarity index 92% rename from src/popup/app/vault/views/vaultEditLogin.html rename to src/popup/app/vault/views/vaultEditCipher.html index 6cc9d4bc..a9877988 100644 --- a/src/popup/app/vault/views/vaultEditLogin.html +++ b/src/popup/app/vault/views/vaultEditCipher.html @@ -1,4 +1,4 @@ -
+
{{i18n.cancel}} @@ -14,24 +14,24 @@ @@ -12,42 +12,42 @@