From 7d2a16c1f486c2f0c311aa90e47746f51f0864ca Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 21 Sep 2016 15:21:50 -0400 Subject: [PATCH] fixes --- .../accounts/views/accountsLoginTwoFactor.html | 2 +- src/popup/app/global/mainController.js | 8 +++++++- src/popup/app/settings/settingsController.js | 2 +- src/popup/app/settings/views/settings.html | 2 +- src/popup/app/vault/vaultController.js | 4 ---- src/services/apiService.js | 7 ++++++- src/services/folderService.js | 16 ++++++++++++---- src/services/siteService.js | 8 ++------ 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/popup/app/accounts/views/accountsLoginTwoFactor.html b/src/popup/app/accounts/views/accountsLoginTwoFactor.html index 49e3accb8c..a43d45682f 100644 --- a/src/popup/app/accounts/views/accountsLoginTwoFactor.html +++ b/src/popup/app/accounts/views/accountsLoginTwoFactor.html @@ -16,7 +16,7 @@
- +
diff --git a/src/popup/app/vault/vaultController.js b/src/popup/app/vault/vaultController.js index 48227b466e..22a8536065 100644 --- a/src/popup/app/vault/vaultController.js +++ b/src/popup/app/vault/vaultController.js @@ -64,10 +64,6 @@ return item.name.toLowerCase(); }; - $scope.filterByFolder = function (folder) { - - }; - $scope.searchSites = function () { if (!$scope.searchText) { return; diff --git a/src/services/apiService.js b/src/services/apiService.js index 5007268b89..1c786b5ccf 100644 --- a/src/services/apiService.js +++ b/src/services/apiService.js @@ -1,4 +1,4 @@ -function ApiService(tokenService) { +function ApiService(tokenService) { this.baseUrl = 'https://api.bitwarden.com'; this.tokenService = tokenService; @@ -269,6 +269,11 @@ function initApiService() { // Helpers function handleError(errorCallback, jqXHR, textStatus, errorThrown) { + if (jqXHR.status === 401 || jqXHR.status === 403) { + chrome.runtime.sendMessage(null, { command: 'logout' }); + return; + } + errorCallback(new ErrorResponse(jqXHR)); } }; diff --git a/src/services/folderService.js b/src/services/folderService.js index 9b3a17e2e4..7678b7ac5a 100644 --- a/src/services/folderService.js +++ b/src/services/folderService.js @@ -1,4 +1,4 @@ -function FolderService(cryptoService, userService, apiService) { +function FolderService(cryptoService, userService, apiService) { this.cryptoService = cryptoService; this.userService = userService; this.apiService = apiService; @@ -29,7 +29,7 @@ function initFolderService() { chrome.storage.local.get(foldersKey, function (obj) { var folders = obj[foldersKey]; - if (id in folders) { + if (folders && id in folders) { callback(new Folder(folders[id])); return; } @@ -97,10 +97,14 @@ function initFolderService() { request = new FolderRequest(folder); if (!folder.id) { - self.apiService.postFolder(request, apiSuccess, handleError); + self.apiService.postFolder(request, apiSuccess, function (response) { + handleError(response, deferred) + }); } else { - self.apiService.putFolder(folder.id, request, apiSuccess, handleError); + self.apiService.putFolder(folder.id, request, apiSuccess, function (response) { + handleError(response, deferred) + }); } function apiSuccess(response) { @@ -219,4 +223,8 @@ function initFolderService() { }); }); }; + + function handleError(error, deferred) { + deferred.reject(error); + } }; diff --git a/src/services/siteService.js b/src/services/siteService.js index 90de4f5053..01c3917463 100644 --- a/src/services/siteService.js +++ b/src/services/siteService.js @@ -1,4 +1,4 @@ -function SiteService(cryptoService, userService, apiService) { +function SiteService(cryptoService, userService, apiService) { this.cryptoService = cryptoService; this.userService = userService; this.apiService = apiService; @@ -43,7 +43,7 @@ function initSiteService() { chrome.storage.local.get(sitesKey, function (obj) { var sites = obj[sitesKey]; - if (id in sites) { + if (sites && id in sites) { callback(new Site(sites[id])); return; } @@ -254,10 +254,6 @@ function initSiteService() { }; function handleError(error, deferred) { - if (error.status === 401 || error.status === 403) { - // TODO: logout - } - deferred.reject(error); } };