1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +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
});
}
else {
chrome.browserAction.setBadgeText({
text: null,
tabId: tabId
});
}
});
});

View File

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

View File

@ -10,6 +10,8 @@ angular
$scope.loaded = false;
loadVault();
function loadVault() {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs.length > 0) {
url = tabs[0].url;
@ -45,6 +47,7 @@ angular
$scope.sites = filteredSites;
});
});
}
$scope.clipboardError = function (e, password) {
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.');
}
};
$scope.$on('syncCompleted', function (event, args) {
setTimeout(loadVault, 500);
});
});

View File

@ -1,7 +1,7 @@
angular
.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 = {};
_service.logIn = function (email, masterPassword) {
@ -21,6 +21,9 @@
if (response.profile) {
userService.setUserId(response.profile.id, function () {
userService.setEmail(response.profile.email, function () {
syncService.fullSync(function () {
$rootScope.$broadcast('syncCompleted');
});
deferred.resolve(response);
});
});
@ -62,15 +65,21 @@
};
_service.logOut = function (callback) {
userService.getUserId(function (userId) {
tokenService.clearToken(function () {
cryptoService.clearKey(function () {
userService.clearUserId(function () {
userService.clearEmail(function () {
siteService.clear(userId, function () {
folderService.clear(userId, function () {
callback();
});
});
});
});
});
});
});
};
return _service;

View File

@ -108,6 +108,10 @@
toastr.info(type + ' copied!');
};
$scope.$on('syncCompleted', function (event, args) {
setTimeout(loadVault, 500);
});
function getScrollY() {
var content = document.getElementsByClassName('content')[0];
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) {
if (!callback || typeof callback !== 'function') {
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) {
if (!callback || typeof callback !== 'function') {
throw 'callback function required';