1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-02 08:30:14 +01:00

clear vault upon logout. full sync vault upon login.

This commit is contained in:
Kyle Spearrin 2016-09-21 00:04:59 -04:00
parent 8b76668f1f
commit 2e56a956db
7 changed files with 86 additions and 40 deletions

View File

@ -103,6 +103,12 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
tabId: tabId tabId: tabId
}); });
} }
else {
chrome.browserAction.setBadgeText({
text: null,
tabId: tabId
});
}
}); });
}); });

View File

@ -25,8 +25,6 @@
$state.go('login.twoFactor'); $state.go('login.twoFactor');
} }
else { else {
// TODO: do full sync
$state.go('tabs.current', { animation: 'in-slide-left' }); $state.go('tabs.current', { animation: 'in-slide-left' });
} }
}); });

View File

@ -10,41 +10,44 @@ angular
$scope.loaded = false; $scope.loaded = false;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { loadVault();
if (tabs.length > 0) { function loadVault() {
url = tabs[0].url; chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
tabId = tabs[0].id; if (tabs.length > 0) {
} url = tabs[0].url;
else { tabId = tabs[0].id;
$scope.loaded = true; }
return; else {
} $scope.loaded = true;
return;
domain = tldjs.getDomain(url);
$scope.sites = [];
if (!domain) {
$scope.loaded = true;
return;
}
chrome.tabs.sendMessage(tabId, { command: 'collectPageDetails' }, function (details) {
pageDetails = details;
canAutofill = true;
});
var filteredSites = [];
var sitePromise = $q.when(siteService.getAllDecrypted());
sitePromise.then(function (sites) {
for (var i = 0; i < sites.length; i++) {
if (sites[i].domain && sites[i].domain === domain) {
filteredSites.push(sites[i]);
}
} }
$scope.loaded = true; domain = tldjs.getDomain(url);
$scope.sites = filteredSites; $scope.sites = [];
if (!domain) {
$scope.loaded = true;
return;
}
chrome.tabs.sendMessage(tabId, { command: 'collectPageDetails' }, function (details) {
pageDetails = details;
canAutofill = true;
});
var filteredSites = [];
var sitePromise = $q.when(siteService.getAllDecrypted());
sitePromise.then(function (sites) {
for (var i = 0; i < sites.length; i++) {
if (sites[i].domain && sites[i].domain === domain) {
filteredSites.push(sites[i]);
}
}
$scope.loaded = true;
$scope.sites = filteredSites;
});
}); });
}); }
$scope.clipboardError = function (e, password) { $scope.clipboardError = function (e, password) {
toastr.info('Your web browser does not support easy clipboard copying. Copy it manually instead.'); toastr.info('Your web browser does not support easy clipboard copying. Copy it manually instead.');
@ -81,4 +84,8 @@ angular
toastr.error('Unable to auto-fill the selected site. Copy/paste your username and/or password instead.'); toastr.error('Unable to auto-fill the selected site. Copy/paste your username and/or password instead.');
} }
}; };
$scope.$on('syncCompleted', function (event, args) {
setTimeout(loadVault, 500);
});
}); });

View File

@ -1,7 +1,7 @@
angular angular
.module('bit.services') .module('bit.services')
.factory('loginService', function (cryptoService, apiService, userService, tokenService, $q) { .factory('loginService', function (cryptoService, apiService, userService, tokenService, $q, syncService, $rootScope, siteService, folderService) {
var _service = {}; var _service = {};
_service.logIn = function (email, masterPassword) { _service.logIn = function (email, masterPassword) {
@ -21,6 +21,9 @@
if (response.profile) { if (response.profile) {
userService.setUserId(response.profile.id, function () { userService.setUserId(response.profile.id, function () {
userService.setEmail(response.profile.email, function () { userService.setEmail(response.profile.email, function () {
syncService.fullSync(function () {
$rootScope.$broadcast('syncCompleted');
});
deferred.resolve(response); deferred.resolve(response);
}); });
}); });
@ -62,11 +65,17 @@
}; };
_service.logOut = function (callback) { _service.logOut = function (callback) {
tokenService.clearToken(function () { userService.getUserId(function (userId) {
cryptoService.clearKey(function () { tokenService.clearToken(function () {
userService.clearUserId(function () { cryptoService.clearKey(function () {
userService.clearEmail(function () { userService.clearUserId(function () {
callback(); userService.clearEmail(function () {
siteService.clear(userId, function () {
folderService.clear(userId, function () {
callback();
});
});
});
}); });
}); });
}); });

View File

@ -108,6 +108,10 @@
toastr.info(type + ' copied!'); toastr.info(type + ' copied!');
}; };
$scope.$on('syncCompleted', function (event, args) {
setTimeout(loadVault, 500);
});
function getScrollY() { function getScrollY() {
var content = document.getElementsByClassName('content')[0]; var content = document.getElementsByClassName('content')[0];
return content.scrollTop; return content.scrollTop;

View File

@ -165,6 +165,17 @@ function initFolderService() {
}); });
}; };
FolderService.prototype.clear = function (userId, callback) {
if (!callback || typeof callback !== 'function') {
throw 'callback function required';
}
chrome.storage.local.remove('folders_' + userId, function () {
self.decryptedFolderCache = null;
callback();
});
};
FolderService.prototype.delete = function (id, callback) { FolderService.prototype.delete = function (id, callback) {
if (!callback || typeof callback !== 'function') { if (!callback || typeof callback !== 'function') {
throw 'callback function required'; throw 'callback function required';

View File

@ -186,6 +186,17 @@ function initSiteService() {
}); });
}; };
SiteService.prototype.clear = function (userId, callback) {
if (!callback || typeof callback !== 'function') {
throw 'callback function required';
}
chrome.storage.local.remove('sites_' + userId, function () {
self.decryptedSiteCache = null;
callback();
});
};
SiteService.prototype.delete = function (id, callback) { SiteService.prototype.delete = function (id, callback) {
if (!callback || typeof callback !== 'function') { if (!callback || typeof callback !== 'function') {
throw 'callback function required'; throw 'callback function required';