diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs
index 0995869c2..b1d5576ce 100644
--- a/src/App/App.xaml.cs
+++ b/src/App/App.xaml.cs
@@ -97,7 +97,8 @@ namespace Bit.App
}
else if(message.Command == "logout")
{
- Device.BeginInvokeOnMainThread(async () => await LogOutAsync(false));
+ Device.BeginInvokeOnMainThread(async () =>
+ await LogOutAsync((message.Data as bool?).GetValueOrDefault()));
}
else if(message.Command == "loggedOut")
{
@@ -240,6 +241,10 @@ namespace Bit.App
_authService.LogOut(() =>
{
Current.MainPage = new HomePage();
+ if(expired)
+ {
+ _platformUtilsService.ShowToast("warning", null, AppResources.LoginExpired);
+ }
});
}
diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs
index d0f4fbfae..f628dad90 100644
--- a/src/App/Pages/Vault/AddEditPageViewModel.cs
+++ b/src/App/Pages/Vault/AddEditPageViewModel.cs
@@ -456,7 +456,10 @@ namespace Bit.App.Pages
catch(ApiException e)
{
await _deviceActionService.HideLoadingAsync();
- await Page.DisplayAlert(AppResources.AnErrorHasOccurred, e.Error.GetSingleMessage(), AppResources.Ok);
+ if(e?.Error != null)
+ {
+ await Page.DisplayAlert(AppResources.AnErrorHasOccurred, e.Error.GetSingleMessage(), AppResources.Ok);
+ }
}
return false;
}
diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs
index dfd59817c..ae4f790db 100644
--- a/src/App/Resources/AppResources.Designer.cs
+++ b/src/App/Resources/AppResources.Designer.cs
@@ -2274,6 +2274,15 @@ namespace Bit.App.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Your login session has expired..
+ ///
+ public static string LoginExpired {
+ get {
+ return ResourceManager.GetString("LoginExpired", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Login.
///
diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx
index 9117b11a0..b7810545d 100644
--- a/src/App/Resources/AppResources.resx
+++ b/src/App/Resources/AppResources.resx
@@ -1575,4 +1575,7 @@
Toggle Visibility
+
+ Your login session has expired.
+
\ No newline at end of file
diff --git a/src/Core/Services/SyncService.cs b/src/Core/Services/SyncService.cs
index 94aea8b4d..8b9ba4479 100644
--- a/src/Core/Services/SyncService.cs
+++ b/src/Core/Services/SyncService.cs
@@ -23,7 +23,7 @@ namespace Bit.Core.Services
private readonly ICollectionService _collectionService;
private readonly IStorageService _storageService;
private readonly IMessagingService _messagingService;
- private readonly Action _logoutCallback;
+ private readonly Func _logoutCallbackAsync;
public SyncService(
IUserService userService,
@@ -35,7 +35,7 @@ namespace Bit.Core.Services
ICollectionService collectionService,
IStorageService storageService,
IMessagingService messagingService,
- Action logoutCallback)
+ Func logoutCallbackAsync)
{
_userService = userService;
_apiService = apiService;
@@ -46,7 +46,7 @@ namespace Bit.Core.Services
_collectionService = collectionService;
_storageService = storageService;
_messagingService = messagingService;
- _logoutCallback = logoutCallback;
+ _logoutCallbackAsync = logoutCallbackAsync;
}
public bool SyncInProgress { get; set; }
@@ -307,7 +307,10 @@ namespace Bit.Core.Services
var stamp = await _userService.GetSecurityStampAsync();
if(stamp != null && stamp != response.SecurityStamp)
{
- _logoutCallback?.Invoke();
+ if(_logoutCallbackAsync != null)
+ {
+ await _logoutCallbackAsync(true);
+ }
return;
}
await _cryptoService.SetEncKeyAsync(response.Key);
diff --git a/src/Core/Utilities/ServiceContainer.cs b/src/Core/Utilities/ServiceContainer.cs
index 498646c94..6d0d330a0 100644
--- a/src/Core/Utilities/ServiceContainer.cs
+++ b/src/Core/Utilities/ServiceContainer.cs
@@ -31,8 +31,11 @@ namespace Bit.Core.Utilities
var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService);
var cryptoService = new CryptoService(storageService, secureStorageService, cryptoFunctionService);
var tokenService = new TokenService(storageService);
- var apiService = new ApiService(tokenService, platformUtilsService, (bool expired) => Task.FromResult(0),
- customUserAgent);
+ var apiService = new ApiService(tokenService, platformUtilsService, (bool expired) =>
+ {
+ messagingService.Send("logout", expired);
+ return Task.FromResult(0);
+ }, customUserAgent);
var appIdService = new AppIdService(storageService);
var userService = new UserService(storageService, tokenService);
var settingsService = new SettingsService(userService, storageService);
@@ -45,8 +48,11 @@ namespace Bit.Core.Utilities
var lockService = new LockService(cryptoService, userService, platformUtilsService, storageService,
folderService, cipherService, collectionService, searchService, messagingService, null);
var syncService = new SyncService(userService, apiService, settingsService, folderService,
- cipherService, cryptoService, collectionService, storageService, messagingService,
- () => messagingService.Send("logout"));
+ cipherService, cryptoService, collectionService, storageService, messagingService, (bool expired) =>
+ {
+ messagingService.Send("logout", expired);
+ return Task.FromResult(0);
+ });
var passwordGenerationService = new PasswordGenerationService(cryptoService, storageService,
cryptoFunctionService);
var totpService = new TotpService(storageService, cryptoFunctionService);