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:
parent
8b76668f1f
commit
2e56a956db
@ -103,6 +103,12 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
|
||||
tabId: tabId
|
||||
});
|
||||
}
|
||||
else {
|
||||
chrome.browserAction.setBadgeText({
|
||||
text: null,
|
||||
tabId: tabId
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
$state.go('login.twoFactor');
|
||||
}
|
||||
else {
|
||||
// TODO: do full sync
|
||||
|
||||
$state.go('tabs.current', { animation: 'in-slide-left' });
|
||||
}
|
||||
});
|
||||
|
@ -10,41 +10,44 @@ angular
|
||||
|
||||
$scope.loaded = false;
|
||||
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||
if (tabs.length > 0) {
|
||||
url = tabs[0].url;
|
||||
tabId = tabs[0].id;
|
||||
}
|
||||
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]);
|
||||
}
|
||||
loadVault();
|
||||
function loadVault() {
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||
if (tabs.length > 0) {
|
||||
url = tabs[0].url;
|
||||
tabId = tabs[0].id;
|
||||
}
|
||||
else {
|
||||
$scope.loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loaded = true;
|
||||
$scope.sites = filteredSites;
|
||||
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;
|
||||
$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);
|
||||
});
|
||||
});
|
||||
|
@ -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,11 +65,17 @@
|
||||
};
|
||||
|
||||
_service.logOut = function (callback) {
|
||||
tokenService.clearToken(function () {
|
||||
cryptoService.clearKey(function () {
|
||||
userService.clearUserId(function () {
|
||||
userService.clearEmail(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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user