Merge pull request #32 from PI20v/24-add-input-checks

Fixes: #24
This commit is contained in:
Maxim Slipenko 2022-05-24 13:52:44 +03:00 committed by GitHub
commit 69a998fe9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 1 deletions

View File

@ -28,7 +28,7 @@ namespace AwesomeEmailExtractor
return new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2));
}
throw new Exception("Пользователь не найден!");
throw new Exception("Неверные данные для входа!");
}
public static User Register(string login, string password)

View File

@ -21,6 +21,12 @@ namespace AwesomeEmailExtractor
{
try
{
if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text))
{
MessageBox.Show("Введите логин и пароль");
return;
}
Globals.currentUser = Authorization.Login(entryLogin.Text, entryPassword.Text);
Logs.Log(Globals.currentUser, Logs.Action.Login, new Dictionary<string, object>());

View File

@ -35,6 +35,12 @@ namespace AwesomeEmailExtractor
private void submitButton_Click(object sender, EventArgs e)
{
if (loginTextBox.Text.Length == 0)
{
MessageBox.Show("Логин не может быть пустым!");
return;
}
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
User editedUser = new User(User.ID, loginTextBox.Text, (UserRoles)roleComboBox.SelectedIndex);

View File

@ -19,6 +19,12 @@ namespace AwesomeEmailExtractor
private void registerButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text))
{
MessageBox.Show("Введите логин и пароль!");
return;
}
if (!string.Equals(entryPassword.Text, entryRePassword.Text))
{
MessageBox.Show("Пароли не совпадают!");

View File

@ -36,6 +36,12 @@ namespace AwesomeEmailExtractor
private void changePasswordButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(entryNewPassword.Text))
{
MessageBox.Show("Введите пароль!");
return;
}
if (!string.Equals(entryNewPassword.Text, entryRePassword.Text))
{
MessageBox.Show("Пароли не совпадают!");