Exemplo n.º 1
0
        private void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            string user = LoginBox.Text;
            string pswd = PasswordBox.Password;

            if (MyAes.EncryptStringToString(pswd).Length <= 255)
            {
                userDto = AppUserOperations.SelectAppUser(user, pswd);
            }

            if (userDto != null)
            {
                AuthBox.Visibility    = Visibility.Visible;
                AuthBtn.Visibility    = Visibility.Visible;
                AuthBox.IsEnabled     = true;
                AuthBtn.IsEnabled     = true;
                LoginBtn.IsEnabled    = false;
                RegisterBtn.IsEnabled = false;

                timer.Start();
                stopwatch.Start();
                try
                {
                    Task.Run(() => { SendAuthCode(user); });
                }
                catch (SmtpException exc)
                {
                    Debug.WriteLine(exc);
                }
            }
            else
            {
                MessageBox.Show("Nieprawidłowe dane logowania.");
            }
        }
        private void AddUserData(string servName, string servPassword, string comment)
        {
            if (MyAes.EncryptStringToString(servPassword).Length > 255)
            {
                MessageBox.Show("Za długie hasło.\nMoże tak się zdarzyć przy zbyt dużej ilości polskich liter.");
                return;
            }
            DataOperations.UserDataOperations.AddUserData(comment, servName, servPassword, DataStatic.LoggedUser.Id);
            int newest = DataOperations.UserDataOperations.SelectNewest(DataStatic.LoggedUser.Id);

            DataOperations.PasswordHistoryOperations.AddPasswordHistory(DateTime.Now, servPassword, newest);
        }
Exemplo n.º 3
0
        private void GetDecryptAndShow()
        {
            dataHist = DataOperations.PasswordHistoryOperations.SelectPasswordHistory(dataId);

            foreach (var passwordHistoryDto in dataHist)
            {
                passwordHistoryDto.PasswordHist = MyAes.DecryptStringToString(passwordHistoryDto.PasswordHist);
            }

            DataHistGrid.ItemsSource           = dataHist;
            DataHistGrid.Columns[0].Visibility = Visibility.Collapsed;
            DataHistGrid.Columns[DataHistGrid.Columns.Count - 1].Width = new DataGridLength(1, DataGridLengthUnitType.Star);
            DataHistGrid.IsReadOnly = true;
        }
Exemplo n.º 4
0
        private void GetDecryptAndShow()
        {
            DataStatic.UserData = DataOperations.UserDataOperations.SelectUserData(DataStatic.LoggedUser.Id);

            foreach (var userDataDto in DataStatic.UserData)
            {
                userDataDto.ServPassword = MyAes.DecryptStringToString(userDataDto.ServPassword);
            }

            UserDataGrid.ItemsSource           = DataStatic.UserData;
            UserDataGrid.Columns[0].Visibility = Visibility.Collapsed;
            UserDataGrid.Columns[UserDataGrid.Columns.Count - 1].Width = new DataGridLength(1, DataGridLengthUnitType.Star);
            UserDataGrid.Columns[1].Header = "Nazwa serwisu";
            UserDataGrid.Columns[2].Header = "Hasło";
            UserDataGrid.Columns[3].Header = "Komentarz";
        }
        private void EditUserData(string servName, string servPassword, string comment)
        {
            if (MyAes.EncryptStringToString(servPassword).Length > 255)
            {
                MessageBox.Show("Za długie hasło.\nMoże tak się zdarzyć przy zbyt dużej ilości polskich liter.");
                return;
            }

            int histCount = DataOperations.PasswordHistoryOperations.SelectPasswordHistoryCount(dataId);

            if (histCount >= 10)
            {
                DataOperations.PasswordHistoryOperations.DeletePasswordHistory(DataOperations.PasswordHistoryOperations.SelectOldest(dataId));
            }

            DataOperations.UserDataOperations.UpdateUserData(comment, servName, servPassword, dataId);
            DataOperations.PasswordHistoryOperations.AddPasswordHistory(DateTime.Now, servPassword, dataId);
        }
Exemplo n.º 6
0
        private void RegisterBtn_Click(object sender, RoutedEventArgs e)
        {
            string user = LoginBox.Text;
            string pswd = PasswordBox.Password;

            if (MyAes.EncryptStringToString(pswd).Length <= 255)
            {
                bool succeeded = AppUserOperations.AddAppUser(user, pswd);

                if (succeeded)
                {
                    MessageBox.Show("Założono nowe konto.");
                }
                else
                {
                    MessageBox.Show("Zakładanie konta nie powiodło się.");
                }
            }
            else
            {
                MessageBox.Show("Zakładanie konta nie powiodło się.");
            }
        }