1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00: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

@@ -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();
});
});
});
});
});