private async Task HandleVaultTimeoutAsync() { if (await _vaultTimeoutService.IsLockedAsync()) { return; } var authed = await _userService.IsAuthenticatedAsync(); if (!authed) { return; } var vaultTimeout = await _storageService.GetAsync <int?>(Constants.VaultTimeoutKey); vaultTimeout = vaultTimeout.GetValueOrDefault(-1); if (vaultTimeout == 0) { var action = await _storageService.GetAsync <string>(Constants.VaultTimeoutActionKey); if (action == "logOut") { await _vaultTimeoutService.LogOutAsync(); } else { await _vaultTimeoutService.LockAsync(true); } } }
private async Task HandleVaultTimeoutAsync() { if (await _vaultTimeoutService.IsLockedAsync()) { return; } var authed = await _userService.IsAuthenticatedAsync(); if (!authed) { return; } // Will only ever be null - look to remove this in the future var vaultTimeout = _platformUtilsService.LockTimeout(); if (vaultTimeout == null) { vaultTimeout = await _storageService.GetAsync <int?>(Constants.VaultTimeoutKey); } vaultTimeout = vaultTimeout.GetValueOrDefault(-1); if (vaultTimeout == 0) { var action = await _storageService.GetAsync <string>(Constants.VaultTimeoutActionKey); if (action == "logOut") { await _vaultTimeoutService.LogOutAsync(); } else { await _vaultTimeoutService.LockAsync(true); } } }
private async void OnMessage(Message message) { try { switch (message.Command) { case AccountsManagerMessageCommands.LOCKED: await Device.InvokeOnMainThreadAsync(() => LockedAsync(message.Data as Tuple <string, bool>)); break; case AccountsManagerMessageCommands.LOCK_VAULT: await _vaultTimeoutService.LockAsync(true); break; case AccountsManagerMessageCommands.LOGOUT: var extras = message.Data as Tuple <string, bool, bool>; var userId = extras?.Item1; var userInitiated = extras?.Item2 ?? true; var expired = extras?.Item3 ?? false; await Device.InvokeOnMainThreadAsync(() => LogOutAsync(userId, userInitiated, expired)); break; case AccountsManagerMessageCommands.LOGGED_OUT: // Clean up old migrated key if they ever log out. await _secureStorageService.RemoveAsync("oldKey"); break; case AccountsManagerMessageCommands.ADD_ACCOUNT: await AddAccountAsync(); break; case AccountsManagerMessageCommands.ACCOUNT_ADDED: await _accountsManagerHost.UpdateThemeAsync(); break; case AccountsManagerMessageCommands.SWITCHED_ACCOUNT: await SwitchedAccountAsync(); break; } } catch (Exception ex) { _logger.Exception(ex); } }
private async void OnMessage(Message message) { switch (message.Command) { case AccountsManagerMessageCommands.LOCKED: Locked(message.Data as Tuple <string, bool>); break; case AccountsManagerMessageCommands.LOCK_VAULT: await _vaultTimeoutService.LockAsync(true); break; case AccountsManagerMessageCommands.LOGOUT: LogOut(message.Data as Tuple <string, bool, bool>); break; case AccountsManagerMessageCommands.LOGGED_OUT: // Clean up old migrated key if they ever log out. await _secureStorageService.RemoveAsync("oldKey"); break; case AccountsManagerMessageCommands.ADD_ACCOUNT: AddAccount(); break; case AccountsManagerMessageCommands.ACCOUNT_ADDED: await _accountsManagerHost.UpdateThemeAsync(); break; case AccountsManagerMessageCommands.SWITCHED_ACCOUNT: await SwitchedAccountAsync(); break; } }
private async void Lock_Clicked(object sender, EventArgs e) { await _vaultTimeoutService.LockAsync(true, true); }
public App(AppOptions appOptions) { Options = appOptions ?? new AppOptions(); if (Options.IosExtension) { Current = this; return; } _userService = ServiceContainer.Resolve <IUserService>("userService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _authService = ServiceContainer.Resolve <IAuthService>("authService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); Bootstrap(); _broadcasterService.Subscribe(nameof(App), async(message) => { if (message.Command == "showDialog") { var details = message.Data as DialogDetails; var confirmed = true; var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? AppResources.Ok : details.ConfirmText; Device.BeginInvokeOnMainThread(async() => { if (!string.IsNullOrWhiteSpace(details.CancelText)) { confirmed = await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText, details.CancelText); } else { await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText); } _messagingService.Send("showDialogResolve", new Tuple <int, bool>(details.DialogId, confirmed)); }); } else if (message.Command == "locked") { await LockedAsync(!(message.Data as bool?).GetValueOrDefault()); } else if (message.Command == "lockVault") { await _vaultTimeoutService.LockAsync(true); } else if (message.Command == "logout") { Device.BeginInvokeOnMainThread(async() => await LogOutAsync((message.Data as bool?).GetValueOrDefault())); } else if (message.Command == "loggedOut") { // Clean up old migrated key if they ever log out. await _secureStorageService.RemoveAsync("oldKey"); } else if (message.Command == "resumed") { if (Device.RuntimePlatform == Device.iOS) { ResumedAsync(); } } else if (message.Command == "slept") { if (Device.RuntimePlatform == Device.iOS) { await SleptAsync(); } } else if (message.Command == "migrated") { await Task.Delay(1000); await SetMainPageAsync(); } else if (message.Command == "popAllAndGoToTabGenerator" || message.Command == "popAllAndGoToTabMyVault" || message.Command == "popAllAndGoToTabSend") { Device.BeginInvokeOnMainThread(async() => { if (Current.MainPage is TabsPage tabsPage) { while (tabsPage.Navigation.ModalStack.Count > 0) { await tabsPage.Navigation.PopModalAsync(false); } if (message.Command == "popAllAndGoToTabMyVault") { Options.MyVaultTile = false; tabsPage.ResetToVaultPage(); } else if (message.Command == "popAllAndGoToTabGenerator") { Options.GeneratorTile = false; tabsPage.ResetToGeneratorPage(); } else if (message.Command == "popAllAndGoToTabSend") { tabsPage.ResetToSendPage(); } } }); } else if (message.Command == "convertAccountToKeyConnector") { Device.BeginInvokeOnMainThread(async() => { await Application.Current.MainPage.Navigation.PushModalAsync( new NavigationPage(new RemoveMasterPasswordPage())); }); } }); }
public async Task LockAsync() { await _vaultTimeoutService.LockAsync(true, true); }
private async void Lock_Clicked(object sender, EventArgs e) { await _accountListOverlay.HideAsync(); await _vaultTimeoutService.LockAsync(true, true); }