Esempio n. 1
0
        private void AuthButton_Click(object sender, RoutedEventArgs e)
        {
            var login = RetrieveLogin();

            var message = "There is no user with this login and password";
            var caption = "Failure!";

            if (_loginChecker.IsCorrect(login) && _passwordChecker.IsStrong(RetrievePassword(), login))
            {
                using var connection = new NpgsqlConnection(BuildConnectionString());
                connection.Open();

                try
                {
                    var salt     = new RetrieveSaltCommand(connection, login).Execute();
                    var password = _hasher.Hash(RetrievePassword(), salt);

                    var passwordMatches = new IsPasswordMatchesCommand(connection, login, password);
                    if (passwordMatches.Execute())
                    {
                        message = "You have successfully authenticated!";
                        caption = "Success!";
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            PostSignUp(message, caption);
        }
Esempio n. 2
0
        private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
        {
            if (!PasswordBox.Password.Any())
            {
                _passwordDecorator.Reset();
                return;
            }

            if (_passwordChecker.IsStrong(RetrievePassword(), RetrieveLogin()))
            {
                _passwordDecorator.InputIsCorrect();
            }
            else
            {
                _passwordDecorator.InputIsIncorrect("Your password isn't strong enough");
            }
        }