diff --git a/src/Core/Services/SyncService.cs b/src/Core/Services/SyncService.cs index 764ddbb0f..2c43c8685 100644 --- a/src/Core/Services/SyncService.cs +++ b/src/Core/Services/SyncService.cs @@ -23,6 +23,7 @@ namespace Bit.Core.Services private readonly ICollectionService _collectionService; private readonly IStorageService _storageService; private readonly IMessagingService _messagingService; + private readonly Action _logoutCallback; public SyncService( IUserService userService, @@ -33,7 +34,8 @@ namespace Bit.Core.Services ICryptoService cryptoService, ICollectionService collectionService, IStorageService storageService, - IMessagingService messagingService) + IMessagingService messagingService, + Action logoutCallback) { _userService = userService; _apiService = apiService; @@ -44,6 +46,7 @@ namespace Bit.Core.Services _collectionService = collectionService; _storageService = storageService; _messagingService = messagingService; + _logoutCallback = logoutCallback; } public bool SyncInProgress { get; set; } @@ -297,8 +300,8 @@ namespace Bit.Core.Services var stamp = await _userService.GetSecurityStampAsync(); if(stamp != null && stamp != response.SecurityStamp) { - // TODO logout callback - throw new Exception("Stamp has changed."); + _logoutCallback?.Invoke(); + return; } await _cryptoService.SetEncKeyAsync(response.Key); await _cryptoService.SetEncPrivateKeyAsync(response.PrivateKey); diff --git a/src/Core/Utilities/ServiceContainer.cs b/src/Core/Utilities/ServiceContainer.cs index f6764d7b2..2c1392866 100644 --- a/src/Core/Utilities/ServiceContainer.cs +++ b/src/Core/Utilities/ServiceContainer.cs @@ -44,7 +44,8 @@ namespace Bit.Core.Utilities var lockService = new LockService(cryptoService, userService, platformUtilsService, storageService, folderService, cipherService, collectionService, searchService, messagingService); var syncService = new SyncService(userService, apiService, settingsService, folderService, - cipherService, cryptoService, collectionService, storageService, messagingService); + cipherService, cryptoService, collectionService, storageService, messagingService, + () => messagingService.Send("logout")); var passwordGenerationService = new PasswordGenerationService(cryptoService, storageService, cryptoFunctionService); var totpService = new TotpService(storageService, cryptoFunctionService);