mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
Added refresh token check for each API call. refactored logout messaging from authService
This commit is contained in:
@@ -190,7 +190,7 @@
|
||||
params: { animation: null }
|
||||
});
|
||||
})
|
||||
.run(function ($rootScope, userService, authService, cryptoService, tokenService, $state, constantsService, stateService) {
|
||||
.run(function ($rootScope, userService, cryptoService, tokenService, $state, constantsService, stateService) {
|
||||
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
|
||||
if ($state.current.name.indexOf('tabs.') > -1 && toState.name.indexOf('tabs.') > -1) {
|
||||
stateService.purgeState();
|
||||
@@ -220,9 +220,7 @@
|
||||
|
||||
if (!isAuthenticated || tokenService.isTokenExpired()) {
|
||||
event.preventDefault();
|
||||
authService.logOut(function () {
|
||||
$state.go('home');
|
||||
});
|
||||
chrome.runtime.sendMessage({ command: 'logout' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
angular
|
||||
.module('bit.global')
|
||||
|
||||
.controller('mainController', function ($scope, $state, authService, toastr, i18nService) {
|
||||
.controller('mainController', function ($scope, $state, authService, toastr, i18nService, $analytics) {
|
||||
var self = this;
|
||||
self.currentYear = new Date().getFullYear();
|
||||
self.animation = '';
|
||||
@@ -23,9 +23,12 @@ angular
|
||||
else if (msg.command === 'syncStarted') {
|
||||
$scope.$broadcast('syncStarted');
|
||||
}
|
||||
else if (msg.command === 'logout') {
|
||||
else if (msg.command === 'doneLoggingOut') {
|
||||
authService.logOut(function () {
|
||||
toastr.warning(i18nService.loginExpired, i18nService.loggedOut);
|
||||
$analytics.eventTrack('Logged Out');
|
||||
if (msg.expired) {
|
||||
toastr.warning(i18nService.loginExpired, i18nService.loggedOut);
|
||||
}
|
||||
$state.go('home');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
angular
|
||||
.module('bit.lock')
|
||||
|
||||
.controller('lockController', function ($scope, $state, $analytics, i18nService, authService, cryptoService, toastr,
|
||||
.controller('lockController', function ($scope, $state, $analytics, i18nService, cryptoService, toastr,
|
||||
userService, SweetAlert) {
|
||||
$scope.i18n = i18nService;
|
||||
$('#master-password').focus();
|
||||
@@ -15,10 +15,7 @@
|
||||
cancelButtonText: i18nService.cancel
|
||||
}, function (confirmed) {
|
||||
if (confirmed) {
|
||||
authService.logOut(function () {
|
||||
$analytics.eventTrack('Logged Out');
|
||||
$state.go('home');
|
||||
});
|
||||
chrome.runtime.sendMessage({ command: 'logout' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -39,30 +39,10 @@
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
// TODO: Fix callback hell by moving to promises
|
||||
_service.logOut = function (callback) {
|
||||
userService.getUserId(function (userId) {
|
||||
syncService.setLastSync(new Date(0), function () {
|
||||
settingsService.clear(function () {
|
||||
tokenService.clearToken(function () {
|
||||
cryptoService.clearKey(function () {
|
||||
cryptoService.clearKeyHash(function () {
|
||||
userService.clearUserIdAndEmail(function () {
|
||||
loginService.clear(userId, function () {
|
||||
folderService.clear(userId, function () {
|
||||
$rootScope.vaultLogins = null;
|
||||
$rootScope.vaultFolders = null;
|
||||
chrome.runtime.sendMessage({ command: 'loggedOut' });
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
$rootScope.vaultLogins = null;
|
||||
$rootScope.vaultFolders = null;
|
||||
callback();
|
||||
};
|
||||
|
||||
return _service;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
angular
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsController', function ($scope, authService, $state, SweetAlert, utilsService, $analytics,
|
||||
.controller('settingsController', function ($scope, $state, SweetAlert, utilsService, $analytics,
|
||||
i18nService, constantsService, cryptoService) {
|
||||
utilsService.initListSectionItemListeners($(document), angular);
|
||||
$scope.lockOption = '';
|
||||
@@ -38,10 +38,7 @@
|
||||
}, function (confirmed) {
|
||||
if (confirmed) {
|
||||
cryptoService.toggleKey(function () { });
|
||||
authService.logOut(function () {
|
||||
$analytics.eventTrack('Logged Out');
|
||||
$state.go('home');
|
||||
});
|
||||
chrome.runtime.sendMessage({ command: 'logout' });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -58,10 +55,7 @@
|
||||
cancelButtonText: i18nService.cancel
|
||||
}, function (confirmed) {
|
||||
if (confirmed) {
|
||||
authService.logOut(function () {
|
||||
$analytics.eventTrack('Logged Out');
|
||||
$state.go('home');
|
||||
});
|
||||
chrome.runtime.sendMessage({ command: 'logout' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user