From f7fd28fded625cc6f7ef4ce422cd25eb1ac8a57b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 2 Jan 2017 22:26:32 -0500 Subject: [PATCH] refactored naming Site => Login --- src/app/global/mainController.js | 4 +- src/app/services/apiService.js | 4 +- src/app/services/cipherService.js | 74 +- src/app/services/importService.js | 638 +++++++++--------- .../settings/settingsChangeEmailController.js | 12 +- .../settingsChangePasswordController.js | 12 +- src/app/tools/toolsExportController.js | 26 +- src/app/tools/toolsImportController.js | 18 +- ...ntroller.js => vaultAddLoginController.js} | 20 +- src/app/vault/vaultController.js | 92 +-- ...troller.js => vaultEditLoginController.js} | 30 +- src/app/vault/views/vault.html | 32 +- .../{vaultAddSite.html => vaultAddLogin.html} | 30 +- ...vaultEditSite.html => vaultEditLogin.html} | 32 +- src/app/views/backendLayout.html | 4 +- src/index.html | 4 +- 16 files changed, 516 insertions(+), 516 deletions(-) rename src/app/vault/{vaultAddSiteController.js => vaultAddLoginController.js} (58%) rename src/app/vault/{vaultEditSiteController.js => vaultEditLoginController.js} (54%) rename src/app/vault/views/{vaultAddSite.html => vaultAddLogin.html} (81%) rename src/app/vault/views/{vaultEditSite.html => vaultEditLogin.html} (80%) diff --git a/src/app/global/mainController.js b/src/app/global/mainController.js index 9259a466e1..578086824d 100644 --- a/src/app/global/mainController.js +++ b/src/app/global/mainController.js @@ -40,8 +40,8 @@ angular $state.go('backend.vault'); }; - $scope.addSite = function () { - $scope.$broadcast('vaultAddSite'); + $scope.addLogin = function () { + $scope.$broadcast('vaultAddLogin'); }; $scope.addFolder = function () { diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index b575f7d302..39105a5c94 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -5,12 +5,12 @@ var _service = {}, _apiUri = appSettings.apiUri; - _service.sites = $resource(_apiUri + '/sites/:id', {}, { + _service.logins = $resource(_apiUri + '/logins/:id', {}, { get: { method: 'GET', params: { id: '@id' } }, list: { method: 'GET', params: {} }, post: { method: 'POST', params: {} }, put: { method: 'POST', params: { id: '@id' } }, - del: { url: _apiUri + '/sites/:id/delete', method: 'POST', params: { id: '@id' } } + del: { url: _apiUri + '/logins/:id/delete', method: 'POST', params: { id: '@id' } } }); _service.folders = $resource(_apiUri + '/folders/:id', {}, { diff --git a/src/app/services/cipherService.js b/src/app/services/cipherService.js index 73268e48f1..469410935e 100644 --- a/src/app/services/cipherService.js +++ b/src/app/services/cipherService.js @@ -4,39 +4,39 @@ angular .factory('cipherService', function (cryptoService, apiService) { var _service = {}; - _service.decryptSites = function (encryptedSites) { - if (!encryptedSites) throw "encryptedSites is undefined or null"; + _service.decryptLogins = function (encryptedLogins) { + if (!encryptedLogins) throw "encryptedLogins is undefined or null"; - var unencryptedSites = []; - for (var i = 0; i < encryptedSites.length; i++) { - unencryptedSites.push(_service.decryptSite(encryptedSites[i])); + var encryptedLogins = []; + for (var i = 0; i < encryptedLogins.length; i++) { + encryptedLogins.push(_service.decryptLogin(encryptedLogins[i])); } - return unencryptedSites; + return encryptedLogins; }; - _service.decryptSite = function (encryptedSite) { - if (!encryptedSite) throw "encryptedSite is undefined or null"; + _service.decryptLogin = function (encryptedLogin) { + if (!encryptedLogin) throw "encryptedLogin is undefined or null"; - var site = { - id: encryptedSite.Id, + var login = { + id: encryptedLogin.Id, 'type': 1, - folderId: encryptedSite.FolderId, - favorite: encryptedSite.Favorite, - name: cryptoService.decrypt(encryptedSite.Name), - uri: encryptedSite.Uri && encryptedSite.Uri !== '' ? cryptoService.decrypt(encryptedSite.Uri) : null, - username: encryptedSite.Username && encryptedSite.Username !== '' ? cryptoService.decrypt(encryptedSite.Username) : null, - password: encryptedSite.Password && encryptedSite.Password !== '' ? cryptoService.decrypt(encryptedSite.Password) : null, - notes: encryptedSite.Notes && encryptedSite.Notes !== '' ? cryptoService.decrypt(encryptedSite.Notes) : null + folderId: encryptedLogin.FolderId, + favorite: encryptedLogin.Favorite, + name: cryptoService.decrypt(encryptedLogin.Name), + uri: encryptedLogin.Uri && encryptedLogin.Uri !== '' ? cryptoService.decrypt(encryptedLogin.Uri) : null, + username: encryptedLogin.Username && encryptedLogin.Username !== '' ? cryptoService.decrypt(encryptedLogin.Username) : null, + password: encryptedLogin.Password && encryptedLogin.Password !== '' ? cryptoService.decrypt(encryptedLogin.Password) : null, + notes: encryptedLogin.Notes && encryptedLogin.Notes !== '' ? cryptoService.decrypt(encryptedLogin.Notes) : null }; - if (encryptedSite.Folder) { - site.folder = { - name: cryptoService.decrypt(encryptedSite.Folder.Name) + if (encryptedLogin.Folder) { + login.folder = { + name: cryptoService.decrypt(encryptedLogin.Folder.Name) }; } - return site; + return login; }; _service.decryptFolders = function (encryptedFolders) { @@ -60,30 +60,30 @@ angular }; }; - _service.encryptSites = function (unencryptedSites, key) { - if (!unencryptedSites) throw "unencryptedSites is undefined or null"; + _service.encryptLogins = function (unencryptedLogins, key) { + if (!unencryptedLogins) throw "unencryptedLogins is undefined or null"; - var encryptedSites = []; - for (var i = 0; i < unencryptedSites.length; i++) { - encryptedSites.push(_service.encryptSite(unencryptedSites[i], key)); + var encryptedLogins = []; + for (var i = 0; i < unencryptedLogins.length; i++) { + encryptedLogins.push(_service.encryptLogin(unencryptedLogins[i], key)); } - return encryptedSites; + return encryptedLogins; }; - _service.encryptSite = function (unencryptedSite, key) { - if (!unencryptedSite) throw "unencryptedSite is undefined or null"; + _service.encryptLogin = function (unencryptedLogin, key) { + if (!unencryptedLogin) throw "unencryptedLogin is undefined or null"; return { - id: unencryptedSite.id, + id: unencryptedLogin.id, 'type': 1, - folderId: unencryptedSite.folderId === '' ? null : unencryptedSite.folderId, - favorite: unencryptedSite.favorite !== null ? unencryptedSite.favorite : false, - uri: !unencryptedSite.uri || unencryptedSite.uri === '' ? null : cryptoService.encrypt(unencryptedSite.uri, key), - name: cryptoService.encrypt(unencryptedSite.name, key), - username: !unencryptedSite.username || unencryptedSite.username === '' ? null : cryptoService.encrypt(unencryptedSite.username, key), - password: !unencryptedSite.password || unencryptedSite.password === '' ? null : cryptoService.encrypt(unencryptedSite.password, key), - notes: !unencryptedSite.notes || unencryptedSite.notes === '' ? null : cryptoService.encrypt(unencryptedSite.notes, key) + folderId: unencryptedLogin.folderId === '' ? null : unencryptedLogin.folderId, + favorite: unencryptedLogin.favorite !== null ? unencryptedLogin.favorite : false, + uri: !unencryptedLogin.uri || unencryptedLogin.uri === '' ? null : cryptoService.encrypt(unencryptedLogin.uri, key), + name: cryptoService.encrypt(unencryptedLogin.name, key), + username: !unencryptedLogin.username || unencryptedLogin.username === '' ? null : cryptoService.encrypt(unencryptedLogin.username, key), + password: !unencryptedLogin.password || unencryptedLogin.password === '' ? null : cryptoService.encrypt(unencryptedLogin.password, key), + notes: !unencryptedLogin.notes || unencryptedLogin.notes === '' ? null : cryptoService.encrypt(unencryptedLogin.notes, key) }; }; diff --git a/src/app/services/importService.js b/src/app/services/importService.js index 6faa97becf..50aadbc311 100644 --- a/src/app/services/importService.js +++ b/src/app/services/importService.js @@ -190,12 +190,12 @@ parseCsvErrors(results); var folders = [], - sites = [], + logins = [], folderRelationships = []; angular.forEach(results.data, function (value, key) { var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = value.folder && value.folder !== '', addFolder = hasFolder; @@ -209,7 +209,7 @@ } } - sites.push({ + logins.push({ favorite: value.favorite !== null ? value.favorite : false, uri: value.uri && value.uri !== '' ? trimUri(value.uri) : null, username: value.username && value.username !== '' ? value.username : null, @@ -226,14 +226,14 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); } }); - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } }); } @@ -293,12 +293,12 @@ function parseData(data) { var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; angular.forEach(data, function (value, key) { var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = value.grouping && value.grouping !== '' && value.grouping !== '(none)', addFolder = hasFolder; @@ -312,7 +312,7 @@ } } - sites.push({ + logins.push({ favorite: value.fav === '1', uri: value.url && value.url !== '' ? trimUri(value.url) : null, username: value.username && value.username !== '' ? value.username : null, @@ -329,14 +329,14 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; - siteRelationships.push(relationship); + loginRelationships.push(relationship); } }); - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } } @@ -348,11 +348,11 @@ parseCsvErrors(results); var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; angular.forEach(results.data, function (value, key) { - sites.push({ + logins.push({ favorite: false, uri: value.URL && value.URL !== '' ? trimUri(value.URL) : null, username: value.Login && value.Login !== '' ? value.Login : null, @@ -362,15 +362,15 @@ }); }); - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } function importSafeInCloudXml(file, success, error) { var folders = [], - sites = [], - siteRelationships = [], + logins = [], + loginRelationships = [], foldersIndex = []; var i = 0, @@ -403,7 +403,7 @@ continue; } - var site = { + var login = { favorite: false, uri: null, username: null, @@ -421,29 +421,29 @@ if (text && text !== '') { if (type === 'login') { - site.username = text; + login.username = text; } else if (type === 'password') { - site.password = text; + login.password = text; } else if (type === 'notes') { - site.notes = text; + login.notes = text; } - else if (type === 'website') { - site.uri = trimUri(text); + else if (type === 'weblogin') { + login.uri = trimUri(text); } } } - sites.push(site); + logins.push(login); labels = card.find('> label_id'); if (labels.length) { var labelId = $(labels[0]).text(); var folderIndex = foldersIndex[labelId]; if (labelId !== null && labelId !== '' && folderIndex !== null) { - siteRelationships.push({ - key: sites.length - 1, + loginRelationships.push({ + key: logins.length - 1, value: folderIndex }); } @@ -451,7 +451,7 @@ } } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } else { error(); @@ -470,7 +470,7 @@ parseCsvErrors(results); var folders = [], - sites = [], + logins = [], folderRelationships = []; var customFieldHeaders = []; @@ -492,7 +492,7 @@ } var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = value[1] && value[1] !== '', addFolder = hasFolder; @@ -506,7 +506,7 @@ } } - var site = { + var login = { favorite: false, uri: null, username: value[2] && value[2] !== '' ? value[2] : null, @@ -524,19 +524,19 @@ var cfHeader = customFieldHeaders[j - 4]; if (cfHeader.toLowerCase() === 'url' || cfHeader.toLowerCase() === 'uri') { - site.uri = trimUri(cf); + login.uri = trimUri(cf); } else { - if (site.notes === null) { - site.notes = ''; + if (login.notes === null) { + login.notes = ''; } - site.notes += cfHeader + ': ' + cf + '\n'; + login.notes += cfHeader + ': ' + cf + '\n'; } } } - sites.push(site); + logins.push(login); if (addFolder) { folders.push({ @@ -546,21 +546,21 @@ if (hasFolder) { folderRelationships.push({ - key: siteIndex, + key: loginIndex, value: folderIndex }); } } - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } }); } function importKeePassXml(file, success, error) { var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; var reader = new FileReader(); reader.readAsText(file, 'utf-8'); @@ -573,7 +573,7 @@ var group = root.find('> Group'); if (group.length) { traverse($(group[0]), true, ''); - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } } else { @@ -604,8 +604,8 @@ if (entries.length) { for (var i = 0; i < entries.length; i++) { var entry = $(entries[i]); - var siteIndex = sites.length; - var site = { + var loginIndex = logins.length; + var login = { favorite: false, uri: null, username: null, @@ -626,37 +626,37 @@ switch (key) { case 'URL': - site.uri = trimUri(value); + login.uri = trimUri(value); break; case 'UserName': - site.username = value; + login.username = value; break; case 'Password': - site.password = value; + login.password = value; break; case 'Title': - site.name = value; + login.name = value; break; case 'Notes': - site.notes = site.notes === null ? value + '\n' : site.notes + value + '\n'; + login.notes = login.notes === null ? value + '\n' : login.notes + value + '\n'; break; default: // other custom fields - site.notes = site.notes === null ? key + ': ' + value + '\n' - : site.notes + key + ': ' + value + '\n'; + login.notes = login.notes === null ? key + ': ' + value + '\n' + : login.notes + key + ': ' + value + '\n'; break; } } - if (site.name === null) { - site.name = '--'; + if (login.name === null) { + login.name = '--'; } - sites.push(site); + logins.push(login); if (!isRootNode) { - siteRelationships.push({ - key: siteIndex, + loginRelationships.push({ + key: loginIndex, value: folderIndex }); } @@ -680,7 +680,7 @@ parseCsvErrors(results); var folders = [], - sites = [], + logins = [], folderRelationships = []; angular.forEach(results.data, function (value, key) { @@ -691,7 +691,7 @@ value.Group.split('/').join(' > ') : null; var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = groupName !== null, addFolder = hasFolder, i = 0; @@ -706,7 +706,7 @@ } } - var site = { + var login = { favorite: false, uri: value.URL && value.URL !== '' ? fixUri(value.URL) : null, username: value.Username && value.Username !== '' ? value.Username : null, @@ -716,7 +716,7 @@ }; if (value.Title) { - sites.push(site); + logins.push(login); } if (addFolder) { @@ -727,46 +727,46 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); } }); - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } }); } function import1Password41Pif(file, success, error) { var folders = [], - sites = [], - siteRelationships = [], + logins = [], + loginRelationships = [], i = 0; - function parseFields(fields, site, designationKey, valueKey, nameKey) { + function parseFields(fields, login, designationKey, valueKey, nameKey) { for (var j = 0; j < fields.length; j++) { var field = fields[j]; if (!field[valueKey] || field[valueKey] === '') { continue; } - if (!site.username && field[designationKey] && field[designationKey] === 'username') { - site.username = field[valueKey]; + if (!login.username && field[designationKey] && field[designationKey] === 'username') { + login.username = field[valueKey]; } - else if (!site.password && field[designationKey] && field[designationKey] === 'password') { - site.password = field[valueKey]; + else if (!login.password && field[designationKey] && field[designationKey] === 'password') { + login.password = field[valueKey]; } else if (field[nameKey] && field[valueKey]) { - if (site.notes === null) { - site.notes = ''; + if (login.notes === null) { + login.notes = ''; } else { - site.notes += '\n'; + login.notes += '\n'; } - site.notes += (field[nameKey] + ': ' + + login.notes += (field[nameKey] + ': ' + field[valueKey].split('\\r\\n').join('\n').split('\\n').join('\n')); } } @@ -785,7 +785,7 @@ } var item = JSON.parse(line); - var site = { + var login = { favorite: item.openContents && item.openContents.faveIndex ? true : false, uri: item.location && item.location !== '' ? fixUri(item.location) : null, username: null, @@ -796,27 +796,27 @@ if (item.secureContents) { if (item.secureContents.notesPlain && item.secureContents.notesPlain !== '') { - site.notes = item.secureContents.notesPlain + login.notes = item.secureContents.notesPlain .split('\\r\\n').join('\n').split('\\n').join('\n'); } if (item.secureContents.fields) { - parseFields(item.secureContents.fields, site, 'designation', 'value', 'name'); + parseFields(item.secureContents.fields, login, 'designation', 'value', 'name'); } if (item.secureContents.sections) { for (var j = 0; j < item.secureContents.sections.length; j++) { if (item.secureContents.sections[j].fields) { - parseFields(item.secureContents.sections[j].fields, site, 'n', 'v', 't'); + parseFields(item.secureContents.sections[j].fields, login, 'n', 'v', 't'); } } } } - sites.push(site); + logins.push(login); } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -826,8 +826,8 @@ function import1Password6Csv(file, success, error) { var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; Papa.parse(file, { encoding: 'UTF-8', @@ -841,7 +841,7 @@ continue; } - var site = { + var login = { favorite: false, uri: null, username: null, @@ -856,45 +856,45 @@ continue; } - if (!site.password && property === 'password') { - site.password = value[property]; + if (!login.password && property === 'password') { + login.password = value[property]; } - else if (!site.username && property === 'username') { - site.username = value[property]; + else if (!login.username && property === 'username') { + login.username = value[property]; } - else if (!site.uri && property === 'urls') { + else if (!login.uri && property === 'urls') { var urls = value[property].split(/(?:\r\n|\r|\n)/); - site.uri = fixUri(urls[0]); + login.uri = fixUri(urls[0]); for (var j = 1; j < urls.length; j++) { - if (site.notes !== '') { - site.notes += '\n'; + if (login.notes !== '') { + login.notes += '\n'; } - site.notes += ('url ' + (j + 1) + ': ' + urls[j]); + login.notes += ('url ' + (j + 1) + ': ' + urls[j]); } } else if (property !== 'ainfo' && property !== 'autosubmit' && property !== 'notesPlain' && property !== 'ps' && property !== 'scope' && property !== 'tags' && property !== 'title' && property !== 'uuid' && !property.startsWith('section:')) { - if (site.notes !== '') { - site.notes += '\n'; + if (login.notes !== '') { + login.notes += '\n'; } - site.notes += (property + ': ' + value[property]); + login.notes += (property + ': ' + value[property]); } } } - if (site.notes === '') { - site.notes = null; + if (login.notes === '') { + login.notes = null; } - sites.push(site); + logins.push(login); } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } @@ -907,11 +907,11 @@ parseCsvErrors(results); var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; angular.forEach(results.data, function (value, key) { - sites.push({ + logins.push({ favorite: false, uri: value.url && value.url !== '' ? trimUri(value.url) : null, username: value.username && value.username !== '' ? value.username : null, @@ -921,15 +921,15 @@ }); }); - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } function importFirefoxPasswordExporterCsvXml(file, success, error) { var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; function getNameFromHost(host) { var name = '--'; @@ -967,7 +967,7 @@ user = entry.attr('user'), password = entry.attr('password'); - sites.push({ + logins.push({ favorite: false, uri: host && host !== '' ? trimUri(host) : null, username: user && user !== '' ? user : null, @@ -977,7 +977,7 @@ }); } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -999,7 +999,7 @@ // parseCsvErrors(results); // angular.forEach(results.data, function (value, key) { - // sites.push({ + // logins.push({ // favorite: false, // uri: value.hostname && value.hostname !== '' ? trimUri(value.hostname) : null, // username: value.username && value.username !== '' ? value.username : null, @@ -1009,7 +1009,7 @@ // }); // }); - // success(folders, sites, siteRelationships); + // success(folders, logins, loginRelationships); // } //}); } @@ -1022,12 +1022,12 @@ parseCsvErrors(results); var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; angular.forEach(results.data, function (value, key) { if (value.length === 5) { - sites.push({ + logins.push({ favorite: false, uri: value[3] && value[3] !== '' ? trimUri(value[3]) : null, username: value[1] && value[1] !== '' ? value[1] : null, @@ -1038,7 +1038,7 @@ } }); - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } @@ -1050,13 +1050,13 @@ parseCsvErrors(results); var folders = [], - sites = [], + logins = [], folderRelationships = []; angular.forEach(results.data, function (value, key) { if (value.length >= 6) { var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = value[0] && value[0] !== '', addFolder = hasFolder, i = 0; @@ -1071,7 +1071,7 @@ } } - var site = { + var login = { favorite: false, uri: value[4] && value[4] !== '' ? trimUri(value[4]) : null, username: value[2] && value[2] !== '' ? value[2] : null, @@ -1083,21 +1083,21 @@ if (value.length > 6) { // we have some custom fields. add them to notes. - if (site.notes === null) { - site.notes = ''; + if (login.notes === null) { + login.notes = ''; } else { - site.notes += '\n'; + login.notes += '\n'; } for (i = 6; i < value.length; i = i + 2) { var cfName = value[i]; var cfValue = value[i + 1]; - site.notes += (cfName + ': ' + cfValue + '\n'); + login.notes += (cfName + ': ' + cfValue + '\n'); } } - sites.push(site); + logins.push(login); if (addFolder) { folders.push({ @@ -1107,7 +1107,7 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); @@ -1115,14 +1115,14 @@ } }); - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } }); } function importPasswordDragonXml(file, success, error) { var folders = [], - sites = [], + logins = [], folderRelationships = [], foldersIndex = [], j = 0; @@ -1155,7 +1155,7 @@ categoryText = category ? category.text() : null; var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = categoryText && categoryText !== '' && categoryText !== 'Unfiled', addFolder = hasFolder; @@ -1169,7 +1169,7 @@ } } - var site = { + var login = { favorite: false, uri: url && url.text() !== '' ? trimUri(url.text()) : null, username: userId && userId.text() !== '' ? userId.text() : null, @@ -1198,18 +1198,18 @@ continue; } - if (site.notes === null) { - site.notes = ''; + if (login.notes === null) { + login.notes = ''; } else { - site.notes += '\n'; + login.notes += '\n'; } - site.notes += (attrName + ': ' + attrValue); + login.notes += (attrName + ': ' + attrValue); } } - sites.push(site); + logins.push(login); if (addFolder) { folders.push({ @@ -1219,7 +1219,7 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); @@ -1227,7 +1227,7 @@ } } - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } else { error(); @@ -1246,8 +1246,8 @@ parseCsvErrors(results); var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; for (var j = 0; j < results.data.length; j++) { var row = results.data[j]; @@ -1259,7 +1259,7 @@ } var note = row[row.length - 1]; - var site = { + var login = { name: row[0], favorite: false, uri: null, @@ -1278,34 +1278,34 @@ var field = row[i + 1]; var fieldLower = field.toLowerCase(); - if (fieldLower === 'url' && !site.uri) { - site.uri = trimUri(value); + if (fieldLower === 'url' && !login.uri) { + login.uri = trimUri(value); } - else if ((fieldLower === 'username' || fieldLower === 'email') && !site.username) { - site.username = value; + else if ((fieldLower === 'username' || fieldLower === 'email') && !login.username) { + login.username = value; } - else if (fieldLower === 'password' && !site.password) { - site.password = value; + else if (fieldLower === 'password' && !login.password) { + login.password = value; } else { // other custom fields - site.notes = site.notes === null ? field + ': ' + value - : site.notes + '\n' + field + ': ' + value; + login.notes = login.notes === null ? field + ': ' + value + : login.notes + '\n' + field + ': ' + value; } } } - sites.push(site); + logins.push(login); } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } function importPasswordSafeXml(file, success, error) { var folders = [], - sites = [], + logins = [], folderRelationships = [], foldersIndex = [], j = 0; @@ -1344,7 +1344,7 @@ groupText = group ? group.text().split('.').join(' > ') : null; var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = groupText && groupText !== '', addFolder = hasFolder; @@ -1358,7 +1358,7 @@ } } - var site = { + var login = { favorite: false, uri: url && url.text() !== '' ? trimUri(url.text()) : null, username: username && username.text() !== '' ? username.text() : null, @@ -1367,15 +1367,15 @@ name: title && title.text() !== '' ? title.text() : '--', }; - if (!site.username && emailText && emailText !== '') { - site.username = emailText; + if (!login.username && emailText && emailText !== '') { + login.username = emailText; } else if (emailText && emailText !== '') { - site.notes = site.notes === null ? 'Email: ' + emailText - : site.notes + '\n' + 'Email: ' + emailText; + login.notes = login.notes === null ? 'Email: ' + emailText + : login.notes + '\n' + 'Email: ' + emailText; } - sites.push(site); + logins.push(login); if (addFolder) { folders.push({ @@ -1385,7 +1385,7 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); @@ -1393,7 +1393,7 @@ } } - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } else { error(); @@ -1412,8 +1412,8 @@ parseCsvErrors(results); var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; for (var j = 0; j < results.data.length; j++) { var skip = false; @@ -1422,7 +1422,7 @@ continue; } - var site = { + var login = { name: row[0] && row[0] !== '' ? row[0] : '--', favorite: false, uri: null, @@ -1432,58 +1432,58 @@ }; if (row.length === 2) { - site.uri = fixUri(row[1]); + login.uri = fixUri(row[1]); } else if (row.length === 3) { - site.uri = fixUri(row[1]); - site.username = row[2]; + login.uri = fixUri(row[1]); + login.username = row[2]; } else if (row.length === 4) { if (row[2] === '' && row[3] === '') { - site.username = row[1]; - site.notes = row[2] + '\n' + row[3]; + login.username = row[1]; + login.notes = row[2] + '\n' + row[3]; } else { - site.username = row[2]; - site.notes = row[1] + '\n' + row[3]; + login.username = row[2]; + login.notes = row[1] + '\n' + row[3]; } } else if (row.length === 5) { - site.uri = fixUri(row[1]); - site.username = row[2]; - site.password = row[3]; - site.notes = row[4]; + login.uri = fixUri(row[1]); + login.username = row[2]; + login.password = row[3]; + login.notes = row[4]; } else if (row.length === 6) { if (row[2] === '') { - site.username = row[3]; - site.notes = row[5]; + login.username = row[3]; + login.notes = row[5]; } else { - site.username = row[2]; - site.notes = row[3] + '\n' + row[5]; + login.username = row[2]; + login.notes = row[3] + '\n' + row[5]; } - site.uri = fixUri(row[1]); - site.password = row[4]; + login.uri = fixUri(row[1]); + login.password = row[4]; } else if (row.length === 7) { if (row[2] === '') { - site.username = row[3]; - site.notes = row[4] + '\n' + row[6]; + login.username = row[3]; + login.notes = row[4] + '\n' + row[6]; } else { - site.username = row[2]; - site.notes = row[3] + '\n' + row[4] + '\n' + row[6]; + login.username = row[2]; + login.notes = row[3] + '\n' + row[4] + '\n' + row[6]; } - site.uri = fixUri(row[1]); - site.password = row[5]; + login.uri = fixUri(row[1]); + login.password = row[5]; } else { - site.notes = ''; + login.notes = ''; for (var i = 1; i < row.length; i++) { - site.notes = site.notes + row[i] + '\n'; + login.notes = login.notes + row[i] + '\n'; if (row[i] === 'NO_TYPE') { skip = true; break; @@ -1495,30 +1495,30 @@ continue; } - if (site.username === '') { - site.username = null; + if (login.username === '') { + login.username = null; } - if (site.password === '') { - site.password = null; + if (login.password === '') { + login.password = null; } - if (site.notes === '') { - site.notes = null; + if (login.notes === '') { + login.notes = null; } - if (site.uri === '') { - site.uri = null; + if (login.uri === '') { + login.uri = null; } - sites.push(site); + logins.push(login); } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } function importStickyPasswordXml(file, success, error) { var folders = [], - sites = [], + logins = [], folderRelationships = [], foldersIndex = [], j = 0; @@ -1544,14 +1544,14 @@ var database = xml.find('root > Database'); if (database.length) { - var logins = database.find('> Logins > Login'); - if (logins.length) { - for (var i = 0; i < logins.length; i++) { - var login = $(logins[i]); + var loginNodes = database.find('> Logins > Login'); + if (loginNodes.length) { + for (var i = 0; i < loginNodes.length; i++) { + var loginNode = $(loginNodes[i]); - var usernameText = login.attr('Name'), - passwordText = login.attr('Password'), - accountId = login.attr('ID'), + var usernameText = loginNode.attr('Name'), + passwordText = loginNode.attr('Password'), + accountId = loginNode.attr('ID'), titleText = null, linkText = null, notesText = null, @@ -1580,7 +1580,7 @@ } var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = groupText && groupText !== '', addFolder = hasFolder; @@ -1594,7 +1594,7 @@ } } - var site = { + var login = { favorite: false, uri: linkText && linkText !== '' ? trimUri(linkText) : null, username: usernameText && usernameText !== '' ? usernameText : null, @@ -1603,7 +1603,7 @@ name: titleText && titleText !== '' ? titleText : '--', }; - sites.push(site); + logins.push(login); if (addFolder) { folders.push({ @@ -1613,7 +1613,7 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); @@ -1621,7 +1621,7 @@ } } - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } else { error(); @@ -1640,13 +1640,13 @@ parseCsvErrors(results); var folders = [], - sites = [], + logins = [], folderRelationships = []; angular.forEach(results.data, function (value, key) { if (value.length >= 3) { var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = value[0] && value[0] !== '' && value[0] !== 'Unassigned', addFolder = hasFolder, i = 0; @@ -1661,7 +1661,7 @@ } } - var site = { + var login = { favorite: false, uri: null, username: null, @@ -1671,32 +1671,32 @@ }; if (value[1] === 'Web Logins') { - site.uri = value[4] && value[4] !== '' ? trimUri(value[4]) : null; - site.username = value[5] && value[5] !== '' ? value[5] : null; - site.password = value[6] && value[6] !== '' ? value[6] : null; - site.notes = value[3] && value[3] !== '' ? value[3].split('\\n').join('\n') : null; + login.uri = value[4] && value[4] !== '' ? trimUri(value[4]) : null; + login.username = value[5] && value[5] !== '' ? value[5] : null; + login.password = value[6] && value[6] !== '' ? value[6] : null; + login.notes = value[3] && value[3] !== '' ? value[3].split('\\n').join('\n') : null; } else if (value.length > 3) { for (var j = 3; j < value.length; j++) { if (value[j] && value[j] !== '') { - if (site.notes !== '') { - site.notes = site.notes + '\n'; + if (login.notes !== '') { + login.notes = login.notes + '\n'; } - site.notes = site.notes + value[j]; + login.notes = login.notes + value[j]; } } } if (value[1] && value[1] !== '' && value[1] !== 'Web Logins') { - site.name = value[1] + ': ' + site.name; + login.name = value[1] + ': ' + login.name; } - if (site.notes === '') { - site.notes = null; + if (login.notes === '') { + login.notes = null; } - sites.push(site); + logins.push(login); if (addFolder) { folders.push({ @@ -1706,7 +1706,7 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); @@ -1714,15 +1714,15 @@ } }); - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } }); } function importTrueKeyJson(file, success, error) { var folders = [], - sites = [], - siteRelationships = [], + logins = [], + loginRelationships = [], i = 0; var reader = new FileReader(); @@ -1734,7 +1734,7 @@ if (fileJson.logins) { for (i = 0; i < fileJson.logins.length; i++) { var login = fileJson.logins[i]; - sites.push({ + logins.push({ favorite: login.favorite && login.favorite === true, uri: login.url && login.url !== '' ? trimUri(login.url) : null, username: login.login && login.login !== '' ? login.login : null, @@ -1786,12 +1786,12 @@ note.notes = note.notes.split('\\n').join('\n'); } - sites.push(note); + logins.push(note); } } } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -1801,8 +1801,8 @@ function importClipperzHtml(file, success, error) { var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; var reader = new FileReader(); reader.readAsText(file, 'utf-8'); @@ -1816,7 +1816,7 @@ for (var i = 0; i < entries.length; i++) { var entry = entries[i]; - var site = { + var login = { favorite: false, uri: null, username: null, @@ -1826,7 +1826,7 @@ }; if (entry.data && entry.data.notes && entry.data.notes !== '') { - site.notes = entry.data.notes.split('\\n').join('\n'); + login.notes = entry.data.notes.split('\\n').join('\n'); } if (entry.currentVersion && entry.currentVersion.fields) { @@ -1837,30 +1837,30 @@ switch (actionType) { case 'password': - site.password = field.value; + login.password = field.value; break; case 'email': case 'username': case 'user': case 'name': - site.username = field.value; + login.username = field.value; break; case 'url': - site.uri = trimUri(field.value); + login.uri = trimUri(field.value); break; case 'none': default: - if (!site.username && isField(field.label, _usernameFieldNames)) { - site.username = field.value; + if (!login.username && isField(field.label, _usernameFieldNames)) { + login.username = field.value; } - else if (!site.password && isField(field.label, _passwordFieldNames)) { - site.password = field.value; + else if (!login.password && isField(field.label, _passwordFieldNames)) { + login.password = field.value; } else { - if (site.notes && site.notes !== '') { - site.notes = site.notes + '\n'; + if (login.notes && login.notes !== '') { + login.notes = login.notes + '\n'; } - site.notes = site.notes + field.label + ': ' + field.value; + login.notes = login.notes + field.label + ': ' + field.value; } break; } @@ -1868,15 +1868,15 @@ } } - if (site.notes === '') { - site.notes = null; + if (login.notes === '') { + login.notes = null; } - sites.push(site); + logins.push(login); } } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -1886,8 +1886,8 @@ function importAviraJson(file, success, error) { var folders = [], - sites = [], - siteRelationships = [], + logins = [], + loginRelationships = [], i = 0; var reader = new FileReader(); @@ -1899,7 +1899,7 @@ if (fileJson.accounts) { for (i = 0; i < fileJson.accounts.length; i++) { var account = fileJson.accounts[i]; - var site = { + var login = { favorite: account.is_favorite && account.is_favorite === true, uri: account.domain && account.domain !== '' ? fixUri(account.domain) : null, username: account.username && account.username !== '' ? account.username : null, @@ -1909,24 +1909,24 @@ }; if (account.email && account.email !== '') { - if (!site.username || site.username === '') { - site.username = account.email; + if (!login.username || login.username === '') { + login.username = account.email; } else { - site.notes = account.email; + login.notes = account.email; } } - if (!site.name || site.name === '') { - site.name = '--'; + if (!login.name || login.name === '') { + login.name = '--'; } - sites.push(site); + logins.push(login); } } } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -1936,8 +1936,8 @@ function importRoboFormHtml(file, success, error) { var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; var reader = new FileReader(); reader.readAsText(file, 'utf-8'); @@ -1947,7 +1947,7 @@ if (outterTables.length) { for (var i = 0; i < outterTables.length; i++) { var outterTable = $(outterTables[i]); - var site = { + var login = { favorite: false, uri: null, username: null, @@ -1958,7 +1958,7 @@ var url = outterTable.find('.subcaption').text(); if (url && url !== '') { - site.uri = fixUri(url); + login.uri = fixUri(url); } var fields = []; @@ -1975,34 +1975,34 @@ var field = fields[j]; var fieldValue = fields[j + 1]; - if (!site.password && isField(field.replace(':', ''), _passwordFieldNames)) { - site.password = fieldValue; + if (!login.password && isField(field.replace(':', ''), _passwordFieldNames)) { + login.password = fieldValue; } - else if (!site.username && isField(field.replace(':', ''), _usernameFieldNames)) { - site.username = fieldValue; + else if (!login.username && isField(field.replace(':', ''), _usernameFieldNames)) { + login.username = fieldValue; } else { - if (site.notes !== '') { - site.notes = site.notes + '\n'; + if (login.notes !== '') { + login.notes = login.notes + '\n'; } - site.notes = site.notes + field + ' ' + fieldValue; + login.notes = login.notes + field + ' ' + fieldValue; } } - if (!site.notes || site.notes === '') { - site.notes = null; + if (!login.notes || login.notes === '') { + login.notes = null; } - if (!site.name || site.name === '') { - site.name = '--'; + if (!login.name || login.name === '') { + login.name = '--'; } - sites.push(site); + logins.push(login); } } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -2018,8 +2018,8 @@ } var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; Papa.parse(file, { header: true, @@ -2028,7 +2028,7 @@ parseCsvErrors(results); angular.forEach(results.data, function (value, key) { - sites.push({ + logins.push({ favorite: false, uri: value.url && value.url !== '' ? trimUri(value.url) : null, username: value.username && value.username !== '' ? value.username : null, @@ -2038,7 +2038,7 @@ }); }); - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } @@ -2050,8 +2050,8 @@ parseCsvErrors(results); var folders = [], - sites = [], - siteRelationships = []; + logins = [], + loginRelationships = []; for (var j = 0; j < results.data.length; j++) { var row = results.data[j]; @@ -2060,7 +2060,7 @@ } var note = row[row.length - 1]; - var site = { + var login = { name: row[0], favorite: false, uri: null, @@ -2079,41 +2079,41 @@ var fieldLower = field.toLowerCase(); - if (!site.uri && isField(field, _uriFieldNames)) { - site.uri = fixUri(value); + if (!login.uri && isField(field, _uriFieldNames)) { + login.uri = fixUri(value); } - else if (!site.username && isField(field, _usernameFieldNames)) { - site.username = value; + else if (!login.username && isField(field, _usernameFieldNames)) { + login.username = value; } - else if (!site.password && isField(field, _passwordFieldNames)) { - site.password = value; + else if (!login.password && isField(field, _passwordFieldNames)) { + login.password = value; } else { - if (!site.notes) { - site.notes = ''; + if (!login.notes) { + login.notes = ''; } else { - site.notes += '\n'; + login.notes += '\n'; } // other custom fields - site.notes += (field + ': ' + value); + login.notes += (field + ': ' + value); } } } - sites.push(site); + logins.push(login); } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); } }); } function importPasswordBossJson(file, success, error) { var folders = [], - sites = [], - siteRelationships = [], + logins = [], + loginRelationships = [], i = 0; var reader = new FileReader(); @@ -2125,7 +2125,7 @@ for (i = 0; i < fileJson.length; i++) { var item = fileJson[i]; - var site = { + var login = { favorite: false, uri: item.login_url && item.login_url !== '' ? fixUri(item.login_url) : null, username: null, @@ -2139,7 +2139,7 @@ } if (item.identifiers.notes && item.identifiers.notes !== '') { - site.notes = item.identifiers.notes.split('\\r\\n').join('\n').split('\\n').join('\n'); + login.notes = item.identifiers.notes.split('\\r\\n').join('\n').split('\\n').join('\n'); } for (var property in item.identifiers) { @@ -2150,30 +2150,30 @@ } if (property === 'username') { - site.username = value; + login.username = value; } else if (property === 'password') { - site.password = value; + login.password = value; } else { - if (site.notes !== '') { - site.notes += '\n'; + if (login.notes !== '') { + login.notes += '\n'; } - site.notes += (property + ': ' + value); + login.notes += (property + ': ' + value); } } } - if (site.notes === '') { - site.notes = null; + if (login.notes === '') { + login.notes = null; } - sites.push(site); + logins.push(login); } } - success(folders, sites, siteRelationships); + success(folders, logins, loginRelationships); }; reader.onerror = function (evt) { @@ -2182,7 +2182,7 @@ } function importZohoVaultCsv(file, success, error) { - function parseData(data, site) { + function parseData(data, login) { if (!data || data === '') { return; } @@ -2203,17 +2203,17 @@ var fieldLower = field.toLowerCase(); if (fieldLower === 'user name') { - site.username = value; + login.username = value; } else if (fieldLower === 'password') { - site.password = value; + login.password = value; } else { - if (site.notes !== '') { - site.notes += '\n'; + if (login.notes !== '') { + login.notes += '\n'; } - site.notes += (field + ': ' + value); + login.notes += (field + ': ' + value); } } } @@ -2225,14 +2225,14 @@ parseCsvErrors(results); var folders = [], - sites = [], + logins = [], folderRelationships = []; angular.forEach(results.data, function (value, key) { var chamber = value['ChamberName']; var folderIndex = folders.length, - siteIndex = sites.length, + loginIndex = logins.length, hasFolder = chamber && chamber !== '', addFolder = hasFolder, i = 0; @@ -2247,7 +2247,7 @@ } } - var site = { + var login = { favorite: value['Favorite'] && value['Favorite'] === '1' ? true : false, uri: value['Secret URL'] && value['Secret URL'] !== '' ? fixUri(value['Secret URL']) : null, username: null, @@ -2256,15 +2256,15 @@ name: value['Secret Name'] && value['Secret Name'] !== '' ? value['Secret Name'] : '--' }; - parseData(value['SecretData'], site); - parseData(value['CustomData'], site); + parseData(value['SecretData'], login); + parseData(value['CustomData'], login); - if (site.notes === '') { - site.notes = null; + if (login.notes === '') { + login.notes = null; } if (value['Secret Name']) { - sites.push(site); + logins.push(login); } if (addFolder) { @@ -2275,14 +2275,14 @@ if (hasFolder) { var relationship = { - key: siteIndex, + key: loginIndex, value: folderIndex }; folderRelationships.push(relationship); } }); - success(folders, sites, folderRelationships); + success(folders, logins, folderRelationships); } }); } diff --git a/src/app/settings/settingsChangeEmailController.js b/src/app/settings/settingsChangeEmailController.js index 6867cd055f..405214e60b 100644 --- a/src/app/settings/settingsChangeEmailController.js +++ b/src/app/settings/settingsChangeEmailController.js @@ -27,10 +27,10 @@ $scope.confirm = function (model) { $scope.processing = true; - var reencryptedSites = []; - var sitesPromise = apiService.sites.list({ dirty: false }, function (encryptedSites) { - var unencryptedSites = cipherService.decryptSites(encryptedSites.Data); - reencryptedSites = cipherService.encryptSites(unencryptedSites, _newKey); + var reencryptedLogins = []; + var loginsPromise = apiService.logins.list({ dirty: false }, function (encryptedLogins) { + var unencryptedLogins = cipherService.decryptLogins(encryptedLogins.Data); + reencryptedLogins = cipherService.encryptLogins(unencryptedLogins, _newKey); }).$promise; var reencryptedFolders = []; @@ -39,13 +39,13 @@ reencryptedFolders = cipherService.encryptFolders(unencryptedFolders, _newKey); }).$promise; - $q.all([sitesPromise, foldersPromise]).then(function () { + $q.all([loginsPromise, foldersPromise]).then(function () { var request = { token: model.token, newEmail: model.newEmail.toLowerCase(), masterPasswordHash: _masterPasswordHash, newMasterPasswordHash: _newMasterPasswordHash, - ciphers: reencryptedSites.concat(reencryptedFolders) + ciphers: reencryptedLogins.concat(reencryptedFolders) }; $scope.confirmPromise = apiService.accounts.email(request, function () { diff --git a/src/app/settings/settingsChangePasswordController.js b/src/app/settings/settingsChangePasswordController.js index 67c1273930..419b581101 100644 --- a/src/app/settings/settingsChangePasswordController.js +++ b/src/app/settings/settingsChangePasswordController.js @@ -27,10 +27,10 @@ var profile = authService.getUserProfile(); var newKey = cryptoService.makeKey(model.newMasterPassword, profile.email.toLowerCase()); - var reencryptedSites = []; - var sitesPromise = apiService.sites.list({ dirty: false }, function (encryptedSites) { - var unencryptedSites = cipherService.decryptSites(encryptedSites.Data); - reencryptedSites = cipherService.encryptSites(unencryptedSites, newKey); + var reencryptedLogins = []; + var loginsPromise = apiService.logins.list({ dirty: false }, function (encryptedLogins) { + var unencryptedLogins = cipherService.decryptLogins(encryptedLogins.Data); + reencryptedLogins = cipherService.encryptLogins(unencryptedLogins, newKey); }).$promise; var reencryptedFolders = []; @@ -39,11 +39,11 @@ reencryptedFolders = cipherService.encryptFolders(unencryptedFolders, newKey); }).$promise; - $q.all([sitesPromise, foldersPromise]).then(function () { + $q.all([loginsPromise, foldersPromise]).then(function () { var request = { masterPasswordHash: cryptoService.hashPassword(model.masterPassword), newMasterPasswordHash: cryptoService.hashPassword(model.newMasterPassword, newKey), - ciphers: reencryptedSites.concat(reencryptedFolders) + ciphers: reencryptedLogins.concat(reencryptedFolders) }; $scope.savePromise = apiService.accounts.putPassword(request, function () { diff --git a/src/app/tools/toolsExportController.js b/src/app/tools/toolsExportController.js index 697ee3f455..ac5fd56e3e 100644 --- a/src/app/tools/toolsExportController.js +++ b/src/app/tools/toolsExportController.js @@ -5,25 +5,25 @@ $analytics.eventTrack('toolsExportController', { category: 'Modal' }); $scope.export = function (model) { $scope.startedExport = true; - apiService.sites.list({ expand: ['folder'] }, function (sites) { + apiService.logins.list({ expand: ['folder'] }, function (logins) { try { - var decSites = cipherService.decryptSites(sites.Data); + var decLogins = cipherService.decryptLogins(logins.Data); - var exportSites = []; - for (var i = 0; i < decSites.length; i++) { - var site = { - name: decSites[i].name, - uri: decSites[i].uri, - username: decSites[i].username, - password: decSites[i].password, - notes: decSites[i].notes, - folder: decSites[i].folder ? decSites[i].folder.name : null + var exportLogins = []; + for (var i = 0; i < decLogins.length; i++) { + var login = { + name: decLogins[i].name, + uri: decLogins[i].uri, + username: decLogins[i].username, + password: decLogins[i].password, + notes: decLogins[i].notes, + folder: decLogins[i].folder ? decLogins[i].folder.name : null }; - exportSites.push(site); + exportLogins.push(login); } - var csvString = Papa.unparse(exportSites); + var csvString = Papa.unparse(exportLogins); var csvBlob = new Blob([csvString]); if (window.navigator.msSaveOrOpenBlob) { // IE hack. ref http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx window.navigator.msSaveBlob(csvBlob, makeFileName()); diff --git a/src/app/tools/toolsImportController.js b/src/app/tools/toolsImportController.js index ee3731f6e1..11c117cbe8 100644 --- a/src/app/tools/toolsImportController.js +++ b/src/app/tools/toolsImportController.js @@ -11,15 +11,15 @@ importService.import(model.source, file, importSuccess, importError); }; - function importSuccess(folders, sites, folderRelationships) { - if (!folders.length && !sites.length) { + function importSuccess(folders, logins, folderRelationships) { + if (!folders.length && !logins.length) { importError('Nothing was imported.'); return; } - else if (sites.length) { - var halfway = Math.floor(sites.length / 2); - var last = sites.length - 1; - if (siteIsBadData(sites[0]) && siteIsBadData(sites[halfway]) && siteIsBadData(sites[last])) { + else if (logins.length) { + var halfway = Math.floor(logins.length / 2); + var last = logins.length - 1; + if (loginIsBadData(logins[0]) && loginIsBadData(logins[halfway]) && loginIsBadData(logins[last])) { importError('CSV data is not formatted correctly. Please check your import file and try again.'); return; } @@ -27,7 +27,7 @@ apiService.ciphers.import({ folders: cipherService.encryptFolders(folders, cryptoService.getKey()), - sites: cipherService.encryptSites(sites, cryptoService.getKey()), + logins: cipherService.encryptLogins(logins, cryptoService.getKey()), folderRelationships: folderRelationships }, function () { $uibModalInstance.dismiss('cancel'); @@ -38,8 +38,8 @@ }, importError); } - function siteIsBadData(site) { - return (site.name === null || site.name === '--') && (site.password === null || site.password === ''); + function loginIsBadData(login) { + return (login.name === null || login.name === '--') && (login.password === null || login.password === ''); } function importError(error) { diff --git a/src/app/vault/vaultAddSiteController.js b/src/app/vault/vaultAddLoginController.js similarity index 58% rename from src/app/vault/vaultAddSiteController.js rename to src/app/vault/vaultAddLoginController.js index ea9a1cac3e..3e3107f958 100644 --- a/src/app/vault/vaultAddSiteController.js +++ b/src/app/vault/vaultAddLoginController.js @@ -1,27 +1,27 @@ angular .module('bit.vault') - .controller('vaultAddSiteController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, passwordService, folders, selectedFolder, $analytics) { - $analytics.eventTrack('vaultAddSiteController', { category: 'Modal' }); + .controller('vaultAddLoginController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, passwordService, folders, selectedFolder, $analytics) { + $analytics.eventTrack('vaultAddLoginController', { category: 'Modal' }); $scope.folders = folders; - $scope.site = { + $scope.login = { folderId: selectedFolder ? selectedFolder.id : null }; $scope.savePromise = null; $scope.save = function (model) { - var site = cipherService.encryptSite(model); - $scope.savePromise = apiService.sites.post(site, function (siteResponse) { - $analytics.eventTrack('Created Site'); - var decSite = cipherService.decryptSite(siteResponse); - $uibModalInstance.close(decSite); + var login = cipherService.encryptLogin(model); + $scope.savePromise = apiService.logins.post(login, function (loginResponse) { + $analytics.eventTrack('Created Login'); + var decLogin = cipherService.decryptLogin(loginResponse); + $uibModalInstance.close(decLogin); }).$promise; }; $scope.generatePassword = function () { - if (!$scope.site.password || confirm('Are you sure you want to overwrite the current password?')) { + if (!$scope.login.password || confirm('Are you sure you want to overwrite the current password?')) { $analytics.eventTrack('Generated Password From Add'); - $scope.site.password = passwordService.generatePassword({ length: 10, special: true }); + $scope.login.password = passwordService.generatePassword({ length: 10, special: true }); } }; diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index 9357d106ff..e0bf2d8923 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -2,35 +2,35 @@ .module('bit.vault') .controller('vaultController', function ($scope, $uibModal, apiService, $filter, cryptoService, authService, toastr, cipherService) { - $scope.sites = []; + $scope.logins = []; $scope.folders = []; - $scope.loadingSites = true; - apiService.sites.list({}, function (sites) { - $scope.loadingSites = false; + $scope.loadingLogins = true; + apiService.logins.list({}, function (logins) { + $scope.loadingLogins = false; - var decSites = []; - for (var i = 0; i < sites.Data.length; i++) { - var decSite = { - id: sites.Data[i].Id, - folderId: sites.Data[i].FolderId, - favorite: sites.Data[i].Favorite + var decLogins = []; + for (var i = 0; i < logins.Data.length; i++) { + var decLogin = { + id: logins.Data[i].Id, + folderId: logins.Data[i].FolderId, + favorite: logins.Data[i].Favorite }; - try { decSite.name = cryptoService.decrypt(sites.Data[i].Name); } - catch (err) { decSite.name = '[error: cannot decrypt]'; } + try { decLogin.name = cryptoService.decrypt(logins.Data[i].Name); } + catch (err) { decLogin.name = '[error: cannot decrypt]'; } - if (sites.Data[i].Username) { - try { decSite.username = cryptoService.decrypt(sites.Data[i].Username); } - catch (err) { decSite.username = '[error: cannot decrypt]'; } + if (logins.Data[i].Username) { + try { decLogin.username = cryptoService.decrypt(logins.Data[i].Username); } + catch (err) { decLogin.username = '[error: cannot decrypt]'; } } - decSites.push(decSite); + decLogins.push(decLogin); } - $scope.sites = decSites; + $scope.logins = decLogins; }, function () { - $scope.loadingSites = false; + $scope.loadingLogins = false; }); $scope.loadingFolders = true; @@ -66,69 +66,69 @@ return item.name.toLowerCase(); }; - $scope.editSite = function (site) { + $scope.editLogin = function (login) { var editModel = $uibModal.open({ animation: true, - templateUrl: 'app/vault/views/vaultEditSite.html', - controller: 'vaultEditSiteController', + templateUrl: 'app/vault/views/vaultEditLogin.html', + controller: 'vaultEditLoginController', resolve: { - siteId: function () { return site.id; }, + loginId: function () { return login.id; }, folders: function () { return $scope.folders; } } }); editModel.result.then(function (returnVal) { if (returnVal.action === 'edit') { - var siteToUpdate = $filter('filter')($scope.sites, { id: returnVal.data.id }, true); + var loginToUpdate = $filter('filter')($scope.logins, { id: returnVal.data.id }, true); - if (siteToUpdate && siteToUpdate.length > 0) { - siteToUpdate[0].folderId = returnVal.data.folderId; - siteToUpdate[0].name = returnVal.data.name; - siteToUpdate[0].username = returnVal.data.username; - siteToUpdate[0].favorite = returnVal.data.favorite; + if (loginToUpdate && loginToUpdate.length > 0) { + loginToUpdate[0].folderId = returnVal.data.folderId; + loginToUpdate[0].name = returnVal.data.name; + loginToUpdate[0].username = returnVal.data.username; + loginToUpdate[0].favorite = returnVal.data.favorite; } } else if (returnVal.action === 'delete') { - var siteToDelete = $filter('filter')($scope.sites, { id: returnVal.data }, true); - if (siteToDelete && siteToDelete.length > 0) { - var index = $scope.sites.indexOf(siteToDelete[0]); + var loginToDelete = $filter('filter')($scope.logins, { id: returnVal.data }, true); + if (loginToDelete && loginToDelete.length > 0) { + var index = $scope.logins.indexOf(loginToDelete[0]); if (index > -1) { - $scope.sites.splice(index, 1); + $scope.logins.splice(index, 1); } } } }); }; - $scope.$on('vaultAddSite', function (event, args) { - $scope.addSite(); + $scope.$on('vaultAddLogin', function (event, args) { + $scope.addLogin(); }); - $scope.addSite = function (folder) { + $scope.addLogin = function (folder) { var addModel = $uibModal.open({ animation: true, - templateUrl: 'app/vault/views/vaultAddSite.html', - controller: 'vaultAddSiteController', + templateUrl: 'app/vault/views/vaultAddLogin.html', + controller: 'vaultAddLoginController', resolve: { folders: function () { return $scope.folders; }, selectedFolder: function () { return folder; } } }); - addModel.result.then(function (addedSite) { - $scope.sites.push(addedSite); + addModel.result.then(function (addedLogin) { + $scope.logins.push(addedLogin); }); }; - $scope.deleteSite = function (site) { - if (!confirm('Are you sure you want to delete this site (' + site.name + ')?')) { + $scope.deleteLogin = function (login) { + if (!confirm('Are you sure you want to delete this login (' + login.name + ')?')) { return; } - apiService.sites.del({ id: site.id }, function () { - var index = $scope.sites.indexOf(site); + apiService.logins.del({ id: login.id }, function () { + var index = $scope.logins.indexOf(login); if (index > -1) { - $scope.sites.splice(index, 1); + $scope.logins.splice(index, 1); } }); }; @@ -187,7 +187,7 @@ return false; } - var sites = $filter('filter')($scope.sites, { folderId: folder.id }); - return sites.length === 0; + var logins = $filter('filter')($scope.logins, { folderId: folder.id }); + return logins.length === 0; }; }); diff --git a/src/app/vault/vaultEditSiteController.js b/src/app/vault/vaultEditLoginController.js similarity index 54% rename from src/app/vault/vaultEditSiteController.js rename to src/app/vault/vaultEditLoginController.js index 630a17f8fd..0022abf8b1 100644 --- a/src/app/vault/vaultEditSiteController.js +++ b/src/app/vault/vaultEditLoginController.js @@ -1,31 +1,31 @@ angular .module('bit.vault') - .controller('vaultEditSiteController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, passwordService, siteId, folders, $analytics) { - $analytics.eventTrack('vaultEditSiteController', { category: 'Modal' }); + .controller('vaultEditLoginController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, passwordService, loginId, folders, $analytics) { + $analytics.eventTrack('vaultEditLoginController', { category: 'Modal' }); $scope.folders = folders; - $scope.site = {}; + $scope.login = {}; - apiService.sites.get({ id: siteId }, function (site) { - $scope.site = cipherService.decryptSite(site); + apiService.logins.get({ id: loginId }, function (login) { + $scope.login = cipherService.decryptLogin(login); }); $scope.save = function (model) { - var site = cipherService.encryptSite(model); - $scope.savePromise = apiService.sites.put({ id: siteId }, site, function (siteResponse) { - $analytics.eventTrack('Edited Site'); - var decSite = cipherService.decryptSite(siteResponse); + var login = cipherService.encryptLogin(model); + $scope.savePromise = apiService.logins.put({ id: loginId }, login, function (loginResponse) { + $analytics.eventTrack('Edited Login'); + var decLogin = cipherService.decryptLogin(loginResponse); $uibModalInstance.close({ action: 'edit', - data: decSite + data: decLogin }); }).$promise; }; $scope.generatePassword = function () { - if (!$scope.site.password || confirm('Are you sure you want to overwrite the current password?')) { + if (!$scope.login.password || confirm('Are you sure you want to overwrite the current password?')) { $analytics.eventTrack('Generated Password From Edit'); - $scope.site.password = passwordService.generatePassword({ length: 10, special: true }); + $scope.login.password = passwordService.generatePassword({ length: 10, special: true }); } }; @@ -53,14 +53,14 @@ } $scope.delete = function () { - if (!confirm('Are you sure you want to delete this site (' + $scope.site.name + ')?')) { + if (!confirm('Are you sure you want to delete this login (' + $scope.login.name + ')?')) { return; } - apiService.sites.del({ id: $scope.site.id }, function () { + apiService.logins.del({ id: $scope.login.id }, function () { $uibModalInstance.close({ action: 'delete', - data: $scope.site.id + data: $scope.login.id }); }); }; diff --git a/src/app/vault/views/vault.html b/src/app/vault/views/vault.html index 7b52be3a59..3dee0fc3b0 100644 --- a/src/app/vault/views/vault.html +++ b/src/app/vault/views/vault.html @@ -1,7 +1,7 @@ 

My Vault - {{folders.length > 0 ? folders.length - 1 : 0}} folders, {{sites.length}} sites + {{folders.length > 0 ? folders.length - 1 : 0}} folders, {{logins.length}} logins

@@ -10,9 +10,9 @@
-

{{folder.name}} {{folderSites.length}} sites

+

{{folder.name}} {{folderLogins.length}} logins

-
-
-
-

Loading sites...

+
+
+

Loading logins...

-
-

No sites in this folder.

- +
+

No logins in this folder.

+
-
+
- + - + - - + +
SiteName Username
- - + + {{site.name}} {{site.username}}{{login.name}} {{login.username}}
diff --git a/src/app/vault/views/vaultAddSite.html b/src/app/vault/views/vaultAddLogin.html similarity index 81% rename from src/app/vault/views/vaultAddSite.html rename to src/app/vault/views/vaultAddLogin.html index 8f79b73010..b04d71f89c 100644 --- a/src/app/vault/views/vaultAddSite.html +++ b/src/app/vault/views/vaultAddLogin.html @@ -1,19 +1,19 @@  -
+