1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

clear vault upon logout. full sync vault upon login.

This commit is contained in:
Kyle Spearrin
2016-09-21 00:04:59 -04:00
parent 8b76668f1f
commit 2e56a956db
7 changed files with 86 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
angular
.module('bit.services')
.factory('loginService', function (cryptoService, apiService, userService, tokenService, $q) {
.factory('loginService', function (cryptoService, apiService, userService, tokenService, $q, syncService, $rootScope, siteService, folderService) {
var _service = {};
_service.logIn = function (email, masterPassword) {
@@ -21,6 +21,9 @@
if (response.profile) {
userService.setUserId(response.profile.id, function () {
userService.setEmail(response.profile.email, function () {
syncService.fullSync(function () {
$rootScope.$broadcast('syncCompleted');
});
deferred.resolve(response);
});
});
@@ -62,11 +65,17 @@
};
_service.logOut = function (callback) {
tokenService.clearToken(function () {
cryptoService.clearKey(function () {
userService.clearUserId(function () {
userService.clearEmail(function () {
callback();
userService.getUserId(function (userId) {
tokenService.clearToken(function () {
cryptoService.clearKey(function () {
userService.clearUserId(function () {
userService.clearEmail(function () {
siteService.clear(userId, function () {
folderService.clear(userId, function () {
callback();
});
});
});
});
});
});