Example #1
0
        /// <summary>
        /// Prompt Update grid on screen
        /// </summary>
        /// <param name="obj"></param>
        private void SecurityScoreUpdateClick(object obj)
        {
            if (obj != null)
            {
                ItemUri = obj as string;

                // Open info screen
                if (ShowUpdatePasswordInfo)
                {
                    UpdatePasswordsInfoDialog dlg = new UpdatePasswordsInfoDialog(Application.Current.MainWindow);
                    dlg.DataContext = this;
                    dlg.ShowDialog();

                    if (NeverShowChecked)
                    {
                        IPBData       pbData = resolver.GetInstanceOf <IPBData>();
                        Configuration configDontShowInfoDialog = new Configuration()
                        {
                            AccountEmail = pbData.ActiveUser,
                            Key          = DefaultProperties.Configuration_Key_SecurityScoreInfo,
                            Value        = true.ToString()
                        };
                        pbData.AddOrUpdateConfiguration(configDontShowInfoDialog);
                    }

                    ShowUpdatePasswordInfo = !NeverShowChecked;
                }
                else
                {
                    // Only update password from browser
                    OpenSiteToUpdatePassword();
                }
            }
        }
 private void btnSafelyStorInfoPopupNext_Click(object sender, RoutedEventArgs e)
 {
     if (resolver != null)
     {
         IPBData pbData = resolver.GetInstanceOf <IPBData>();
         pbData.AddOrUpdateConfiguration(new Configuration()
         {
             AccountEmail = pbData.ActiveUser, Key = "ShowPasswordGeneratorMiniTour", Value = false.ToString()
         });
     }
     this.Close();
 }
Example #3
0
 private void btnFavoriteSitesNext_Click(object sender, RoutedEventArgs e)
 {
     if (resolver != null)
     {
         IPBData pbData = resolver.GetInstanceOf <IPBData>();
         pbData.AddOrUpdateConfiguration(new Configuration()
         {
             AccountEmail = pbData.ActiveUser, Key = "ShowShareCenterMiniTour", Value = false.ToString()
         });
     }
     this.Close();
 }
Example #4
0
 private void btnNewItemPopupNext_Click(object sender, RoutedEventArgs e)
 {
     if (resolver != null)
     {
         IPBData pbData = resolver.GetInstanceOf <IPBData>();
         pbData.AddOrUpdateConfiguration(new Configuration()
         {
             AccountEmail = pbData.ActiveUser, Key = "ShowDigitalWalletMiniTour", Value = false.ToString()
         });
     }
     this.Close();
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (NeverShowCheckBox.IsChecked.Value)
     {
         IPBData       pbData = resolver.GetInstanceOf <IPBData>();
         Configuration configDontShowInfoDialog = new Configuration()
         {
             AccountEmail = pbData.ActiveUser,
             Key          = DefaultProperties.Configuration_Key_PasswordVaultInfo,
             Value        = true.ToString()
         };
         pbData.AddOrUpdateConfiguration(configDontShowInfoDialog);
     }
     this.Close();
 }
Example #6
0
        /// <summary>
        /// Language selection from combobox and binding dictionary based on selection
        /// </summary>
        /// <param name="sender"></param>
        private void LanguageSelectionChanged(object sender)
        {
            var languageComboBox = sender as ComboBox;

            if (languageComboBox == null)
            {
                return;
            }
            var selectedItem = (KeyValuePair <string, string>)languageComboBox.SelectedItem;

            Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo(selectedItem.Key);
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(selectedItem.Key);

            //TODO save languag to DB
            Configuration config = new Configuration()
            {
                AccountEmail = DefaultProperties.Configuration_DefaultAccount, Key = "last_lang", Value = selectedItem.Key
            };

            pbData.AddOrUpdateConfiguration(config);
            pbData.ChangeDefaultSetting("last_selected_lang", selectedItem.Key);
            ((PBApp)System.Windows.Application.Current).SetLanguage(selectedItem.Key);

            //Disable Topmost property that is required only on Login language screen
            var _loginWindowInstance = _systemTray.CurrentWindow(CurrentLoginWindow);

            _loginWindowInstance.Topmost = false;

            inAppAnalyitics.Get <Events.AccountCreationFlow, AccountCreationFlowItem>().Log(new AccountCreationFlowItem(1, AccountCreationFlowSteps.LanguageSelection, selectedItem.Value, MarketingActionType.Continue));

            var loginWindow = ((PBApp)System.Windows.Application.Current).FindWindow <LoginWindow>();

            if (loginWindow == null)
            {
                throw new ApplicationException("Login language viewmodel, login window null");
            }

            //Navigator.NavigationService.Navigate(loginWindow.Login);
            loginWindow.NavigateloginScreens(!this.pbData.AnyAccountExists() ? "AccountCreation" : null);
        }
        public void Show(Window parent)
        {
            IsShown = true;

            Task.Factory.StartNew(() =>
            {
                Application.Current.Dispatcher.BeginInvoke((Action)(() =>
                {
                    if (_content == null)
                    {
                        _content = StartScreenFactory.CreateStartupWindow(_resolver);
                    }

                    _content.Closing += onContentClosing;

                    if (parent != null)
                    {
                        _content.Owner = parent;
                        _content.Left = parent.Left;
                        _content.Top = parent.Top;
                        _content.Width = parent.ActualWidth;
                        _content.Height = parent.ActualHeight;
                        _content.WindowStartupLocation = parent.WindowState == WindowState.Maximized ? WindowStartupLocation.CenterOwner : WindowStartupLocation.Manual;
                    }

                    _content.Show();

                    Configuration configDontShowOnStartup = new Configuration()
                    {
                        AccountEmail = _pbData.ActiveUser,
                        Key = DefaultProperties.Configuration_Key_ProductTourOnStartup,
                        Value = true.ToString()
                    };

                    _pbData.AddOrUpdateConfiguration(configDontShowOnStartup);
                }));
            });
        }
        private bool TryToShowMainWindow(bool isAuthenticated)
        {
            logger.Debug("TryToShowMainWindow called; isAuthenticated - {0}", isAuthenticated);
            if (!isAuthenticated)
            {
                logger.Error("Cant show main window - not authenticated");
                return(false);
            }

            logger.Debug("Getting device");
            Device device = pbData.GetDevice(pbData.InstallationUUID);

            if (device != null)
            {
                pbData.DeviceUUID = device.UUID;
                logger.Debug("found device - {0}", pbData.DeviceUUID);
            }
            else
            {
                logger.Error("Cant find device");
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    string _message = System.Windows.Application.Current.FindResource("ProblemReadingDeviceIdLoginMessage") as string;
                    CustomInformationMessageBoxWindow c = new CustomInformationMessageBoxWindow(_message);
                    c.ShowDialog();
                });

                return(true);
            }

            IPBWebAPI pbWebAPI = resolver.GetInstanceOf <IPBWebAPI>();


            logger.Debug("Get countries");
            if (pbData.GetCountries().Count == 0)
            {
                logger.Debug("Get countries - request from web API");
                dynamic countries = pbWebAPI.RequestCountry(String.Format("{0}|{1}", pbData.ActiveUser, pbData.DeviceUUID));
                pbData.AddCounties(countries);
            }


            logger.Debug("GetConfigurationByAccountAndKey {0} < {1}", UserEmail, DefaultProperties.Configuration_Key_RememberEmail);
            var rememberLoginEmail = pbData.GetConfigurationByAccountAndKey(UserEmail, DefaultProperties.Configuration_Key_RememberEmail);

            if (rememberLoginEmail == null)
            {
                logger.Debug("GetConfigurationByAccountAndKey failed, adding configuration");
                rememberLoginEmail = new Configuration()
                {
                    AccountEmail = UserEmail,
                    Key          = DefaultProperties.Configuration_Key_RememberEmail,
                    Value        = true.ToString()
                };
                pbData.AddOrUpdateConfiguration(rememberLoginEmail);
                logger.Debug("Condifuration added");
            }
            bool isEnabledRememberLoginEmail = false;

            logger.Debug("TRying to parse rememberLoginEmail");
            if (bool.TryParse(rememberLoginEmail.Value, out isEnabledRememberLoginEmail))
            {
                logger.Debug("rememberLoginEmail parsed - {0}", isEnabledRememberLoginEmail);
                if (isEnabledRememberLoginEmail)
                {
                    var lastLogin = new Configuration()
                    {
                        AccountEmail = DefaultProperties.Configuration_DefaultAccount,
                        Key          = DefaultProperties.Configuration_Key_LastLoginEmail,
                        Value        = UserEmail
                    };
                    pbData.AddOrUpdateConfiguration(lastLogin);
                    logger.Debug("Configuration updated");
                }
            }

            bool isDeviceTrusted    = false;
            var  isDeviceTrustedStr = pbData.GetPrivateSetting(DefaultProperties.Settings_Device_IsDeviceTrusted);

            if (!string.IsNullOrWhiteSpace(isDeviceTrustedStr))
            {
                bool.TryParse(isDeviceTrustedStr, out isDeviceTrusted);
            }

            logger.Debug("IsDeviceTrusted - {0}", isDeviceTrusted);

            if (isDeviceTrusted)
            {
                DateTimeOffset lastCheckedDateTimeOffset     = new DateTimeOffset();
                DateTime       lastCheckedDate               = new DateTime();
                var            isDeviceTrustedLastCheckedStr = pbData.GetPrivateSetting(DefaultProperties.Settings_Device_IsDeviceTrustedLastChecked);
                bool           isParsed = DateTimeOffset.TryParse(isDeviceTrustedLastCheckedStr, out lastCheckedDateTimeOffset);
                if (isParsed)
                {
                    lastCheckedDate = lastCheckedDateTimeOffset.UtcDateTime;
                    var totalDaysCount = (DateTime.UtcNow - lastCheckedDate).TotalDays;

                    if (totalDaysCount > DefaultProperties.Settings_Device_IsDeviceTrustedLastCheckedMinDays)
                    {
                        logger.Debug("device not trusted - totalDaysCount > DefaultProperties.Settings_Device_IsDeviceTrustedLastCheckedMinDays");
                        isDeviceTrusted = false;                         //notify we need to enter this info
                    }
                }
                else
                {
                    isDeviceTrusted = false;
                }
            }
            logger.Debug("IsTurningPassSavingExecuted - {0}", IsTurningPassSavingExecuted);

            if (!IsTurningPassSavingExecuted)
            {
                IsTurningPassSavingExecuted = true;
                bool turnOffPassSaving = false;
                Boolean.TryParse(pbData.GetPrivateSetting(DefaultProperties.Settings_Advanced_TurnOffPassSaving), out turnOffPassSaving);

                logger.Debug("TurnOffPassSaving - {0}", turnOffPassSaving);
                if (turnOffPassSaving)
                {
                    pbData.DisableStoringPasswordInBrowsers();
                }
                else
                {
                    pbData.EnableStoringPasswordInBrowsers();
                }
            }
            //Task.Factory.StartNew(() => CheckRSA(generateKeysStep, pbData, webApi));
            logger.Debug("CheckRsa Calling generateKeysStep - {0}", generateKeysStep);
            CheckRSA(generateKeysStep, pbData, webApi);

            //pbData.TryToClearMessageHistory();

            logger.Debug("OpenMainUI - {0}", OpenMainUI);
            if (OpenMainUI)
            {
                ShowMainWindowIfNeeded(isDeviceTrusted);
            }
            else
            {
                Application.Current.Dispatcher.BeginInvoke((Action)(() =>
                {
                    CloseLoginWindow();
                    MainWindow mainWindow = ((PBApp)Application.Current).FindWindow <MainWindow>();
                    if (mainWindow == null)
                    {
                        mainWindow = new MainWindow(resolver);
                    }
                }));
            }

            return(true);
        }
        public static void SetDefaultSettings(IPBData pbData)
        {
            string tmpCloudEnabled = pbData.GetPrivateSetting(DefaultProperties.Settings_CloudStorage);

            if (tmpCloudEnabled == null)
            {
                pbData.ChangePrivateSetting(DefaultProperties.Settings_CloudStorage, bool.TrueString);
            }

            var rememberLoginEmail = pbData.GetConfigurationByAccountAndKey(pbData.ActiveUser, DefaultProperties.Configuration_Key_RememberEmail);

            if (rememberLoginEmail == null)
            {
                rememberLoginEmail = new Configuration()
                {
                    AccountEmail = pbData.ActiveUser,
                    Key          = DefaultProperties.Configuration_Key_RememberEmail,
                    Value        = true.ToString()
                };
                pbData.AddOrUpdateConfiguration(rememberLoginEmail);
            }
            bool isEnabledRememberLoginEmail = false;

            if (bool.TryParse(rememberLoginEmail.Value, out isEnabledRememberLoginEmail) && isEnabledRememberLoginEmail)
            {
                var lastLogin = new Configuration()
                {
                    AccountEmail = DefaultProperties.Configuration_DefaultAccount,
                    Key          = DefaultProperties.Configuration_Key_LastLoginEmail,
                    Value        = pbData.ActiveUser
                };
                pbData.AddOrUpdateConfiguration(lastLogin);
            }

            string autoLogin = pbData.GetPrivateSetting(DefaultProperties.Settings_Advanced_AutoLogin);

            if (autoLogin == null)
            {
                pbData.ChangePrivateSetting(DefaultProperties.Settings_Advanced_AutoLogin, bool.TrueString);
            }

            string passwordSavingInBrowser = pbData.GetPrivateSetting(DefaultProperties.Settings_Advanced_TurnOffPassSaving);

            if (passwordSavingInBrowser == null)
            {
                pbData.ChangePrivateSetting(DefaultProperties.Settings_Advanced_TurnOffPassSaving, bool.TrueString);
            }

            string autoStoreData = pbData.GetPrivateSetting(DefaultProperties.Settings_Advanced_AutoStoreData);

            if (autoStoreData == null)
            {
                pbData.ChangePrivateSetting(DefaultProperties.Settings_Advanced_AutoStoreData, bool.TrueString);
            }

            var userInfo = pbData.GetUserInfo(pbData.ActiveUser);

            if (userInfo != null && userInfo.StorageRegionUUID == null)
            {
                var region = pbData.GetStorageRegions().FirstOrDefault();

                if (region != null)
                {
                    pbData.UpdateCurrentStorageRegion(region.UUID);
                }
            }
        }
        private void AlertItemClick(object obj)
        {
            if (obj == null)
            {
                return;
            }
            var a = ((Alert)obj).AlertNotification;

            if (!string.IsNullOrWhiteSpace(a.secure_item_id))
            {
                var _secureItem = db.GetSecureItemById(a.secure_item_id);
                if (_secureItem != null && _secureItem.Site != null)
                {
                    ItemUri = _secureItem.LoginUrl;
                }
            }

            if (a.AlertType == AlertType.SecurityAlert)
            {
                // Open info screen
                if (ShowUpdatePasswordInfo)
                {
                    UpdatePasswordsInfoDialog dlg = new UpdatePasswordsInfoDialog(Application.Current.MainWindow);
                    dlg.DataContext = this;
                    dlg.ShowDialog();


                    if (NeverShowChecked)
                    {
                        Configuration configDontShowInfoDialog = new Configuration()
                        {
                            AccountEmail = db.ActiveUser,
                            Key          = DefaultProperties.Configuration_Key_SecurityScoreInfo,
                            Value        = true.ToString()
                        };
                        db.AddOrUpdateConfiguration(configDontShowInfoDialog);
                    }

                    ShowUpdatePasswordInfo = !NeverShowChecked;
                }

                // Only update password from browser
                else
                {
                    OpenSiteToUpdatePassword();
                }

                //var dictionary = new Dictionary<string, object> { { "id", a.secure_item_id } };
                //((IAppCommand)System.Windows.Application.Current).ExecuteCommand("ShowSecureItemEditor", dictionary);
            }
            else if (a.AlertType == AlertType.NewShare)
            {
                if (((Alert)obj).shareStatus == ShareStatus.Pending)
                {
                    ((MainWindow)Application.Current.MainWindow).MenuSetFocus();
                    var dictionary = new Dictionary <string, object> {
                        { "id", ((Alert)obj).uuid }
                    };
                    ((IAppCommand)System.Windows.Application.Current).ExecuteCommand("ShowShareItemInShareCenter", dictionary);
                }
            }
            if (alertPop != null)
            {
                alertPop.IsOpen = false;
            }
        }