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:
parent
80945bd3bc
commit
f84bfcb19a
@ -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 () { });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -42,4 +42,7 @@
|
||||
})
|
||||
.factory('constantsService', function () {
|
||||
return chrome.extension.getBackgroundPage().constantsService;
|
||||
})
|
||||
.factory('settingsService', function () {
|
||||
return chrome.extension.getBackgroundPage().settingsService;
|
||||
});
|
||||
|
@ -13,7 +13,7 @@
|
||||
if (syncOnLoad) {
|
||||
$scope.$on('$viewContentLoaded', function () {
|
||||
$timeout(function () {
|
||||
syncService.fullSync(function () { });
|
||||
syncService.fullSync(true, function () { });
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user