1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +00:00

pass logout function to api service rather than relying on messaging

This commit is contained in:
Kyle Spearrin
2017-01-21 20:00:25 -05:00
parent e288ade266
commit e1ed7587dc
2 changed files with 46 additions and 35 deletions

View File

@@ -5,7 +5,7 @@ var constantsService = new ConstantsService();
var utilsService = new UtilsService();
var cryptoService = new CryptoService(constantsService);
var tokenService = new TokenService();
var apiService = new ApiService(tokenService);
var apiService = new ApiService(tokenService, logout);
var userService = new UserService(tokenService, apiService, cryptoService);
var settingsService = new SettingsService(userService);
var loginService = new LoginService(cryptoService, userService, apiService, settingsService);
@@ -39,10 +39,7 @@ chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
refreshBadgeAndMenu();
}
else if (msg.command === 'logout') {
logout(msg.expired, function () {
setIcon();
refreshBadgeAndMenu();
});
logout(msg.expired, function () { });
}
else if (msg.command === 'syncCompleted' && msg.successfully) {
setTimeout(refreshBadgeAndMenu, 2000);
@@ -627,6 +624,8 @@ function logout(expired, callback) {
loginService.clear(userId, function () {
folderService.clear(userId, function () {
chrome.runtime.sendMessage({ command: 'doneLoggingOut', expired: expired });
setIcon();
refreshBadgeAndMenu();
callback();
});
});