1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-24 16:49:26 +01:00

fix sync bugs on login/logout

This commit is contained in:
Kyle Spearrin 2017-01-17 21:43:26 -05:00
parent 80945bd3bc
commit f84bfcb19a
6 changed files with 24 additions and 23 deletions

View File

@ -622,7 +622,7 @@ function fullSync(override) {
syncService.getLastSync(function (lastSync) {
var now = new Date();
if (override || !lastSync || (now - lastSync) >= syncInternal) {
syncService.fullSync(override, function () { });
syncService.fullSync(override || false, function () { });
}
});
}

View File

@ -2,7 +2,7 @@
.module('bit.services')
.factory('authService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, loginService,
folderService) {
folderService, settingsService, syncService) {
var _service = {};
_service.logIn = function (email, masterPassword) {
@ -66,19 +66,24 @@
return deferred.promise;
};
// TODO: Fix callback hell by moving to promises
_service.logOut = function (callback) {
userService.getUserId(function (userId) {
tokenService.clearToken(function () {
cryptoService.clearKey(function () {
cryptoService.clearKeyHash(function () {
userService.clearUserId(function () {
userService.clearEmail(function () {
loginService.clear(userId, function () {
folderService.clear(userId, function () {
$rootScope.vaultLogins = null;
$rootScope.vaultFolders = null;
chrome.runtime.sendMessage({ command: 'loggedOut' });
callback();
syncService.setLastSync(new Date(0), function () {
settingsService.clear(function () {
tokenService.clearToken(function () {
cryptoService.clearKey(function () {
cryptoService.clearKeyHash(function () {
userService.clearUserId(function () {
userService.clearEmail(function () {
loginService.clear(userId, function () {
folderService.clear(userId, function () {
$rootScope.vaultLogins = null;
$rootScope.vaultFolders = null;
chrome.runtime.sendMessage({ command: 'loggedOut' });
callback();
});
});
});
});
});

View File

@ -42,4 +42,7 @@
})
.factory('constantsService', function () {
return chrome.extension.getBackgroundPage().constantsService;
})
.factory('settingsService', function () {
return chrome.extension.getBackgroundPage().settingsService;
});

View File

@ -13,7 +13,7 @@
if (syncOnLoad) {
$scope.$on('$viewContentLoaded', function () {
$timeout(function () {
syncService.fullSync(function () { });
syncService.fullSync(true, function () { });
}, 0);
});
}

View File

@ -137,11 +137,8 @@ function initLoginService() {
var eqDomainsPromise = self.settingsService.getEquivalentDomains().then(function (eqDomains) {
var matchingDomains = [];
for (var i = 0; i < eqDomains.length; i++) {
for (var j = 0; j < eqDomains[i].length; j++) {
if (eqDomains[i][j] === domain) {
matchingDomains = matchingDomains.concat(eqDomains[i]);
break;
}
if (eqDomains[i].length && eqDomains[i].indexOf(domain) >= 0) {
matchingDomains = matchingDomains.concat(eqDomains[i]);
}
}

View File

@ -230,10 +230,6 @@ function initSyncService() {
throw 'callback function required';
}
if (!(date instanceof Date)) {
throw 'date must be a Date object';
}
this.userService.getUserId(function (userId) {
var lastSyncKey = 'lastSync_' + userId;