добавляет смену пароля

This commit is contained in:
Maxim Slipenko 2022-05-22 11:08:55 +03:00
parent c412738640
commit 121abac88e
Signed by: Maks1mS
GPG Key ID: 7461AF39A8705FB8
3 changed files with 32 additions and 4 deletions

View File

@ -91,13 +91,28 @@ namespace AwesomeEmailExtractor
{
SqliteCommand command = new SqliteCommand();
command.Connection = Globals.db;
command.CommandText = "DELETE FROM users WHERE id = @id";
command.CommandText = "DELETE FROM users WHERE id = @id;";
SqliteParameter loginParam = new SqliteParameter("@id", ID);
command.Parameters.Add(loginParam);
SqliteParameter idParam = new SqliteParameter("@id", ID);
command.Parameters.Add(idParam);
command.ExecuteNonQuery();
}
public void ChangePassword(string password)
{
SqliteCommand command = new SqliteCommand();
command.Connection = Globals.db;
command.CommandText = "UPDATE users SET password = @password WHERE id = @id;";
SqliteParameter idParam = new SqliteParameter("@id", ID);
command.Parameters.Add(idParam);
SqliteParameter passwordParam = new SqliteParameter("@password", Authorization.EncryptPassword(password));
command.Parameters.Add(passwordParam);
command.ExecuteNonQuery();
}
}
public class AdminUtils

View File

@ -44,6 +44,7 @@
this.changePasswordButton.TabIndex = 0;
this.changePasswordButton.Text = "Изменить пароль";
this.changePasswordButton.UseVisualStyleBackColor = true;
this.changePasswordButton.Click += new System.EventHandler(this.changePasswordButton_Click);
//
// entryNewPassword
//

View File

@ -24,7 +24,7 @@ namespace AwesomeEmailExtractor
if (result == DialogResult.Yes)
{
Globals.currentUser.Delete();
MessageBox.Show("Аккаунт удален");
MessageBox.Show("Аккаунт удален!");
this.Close();
@ -32,5 +32,17 @@ namespace AwesomeEmailExtractor
FormManager.Current.Navigate(this.Owner, authorization);
}
}
private void changePasswordButton_Click(object sender, EventArgs e)
{
if (!string.Equals(entryNewPassword.Text, entryRePassword.Text))
{
MessageBox.Show("Пароли не совпадают!");
return;
}
Globals.currentUser.ChangePassword(entryNewPassword.Text);
MessageBox.Show("Пароль изменен!");
}
}
}