private async Task <bool> ValidOldEmail(string OldEmailText) { if (ValidatorClass.IsValidEmail(OldEmailText) == true) { string MD5Login = DatabaseLogicClass.SQLiteGet("SELECT login FROM logins WHERE authenticated=1"); string result = await DatabaseLogicClass.MySQLGetAsync("SELECT Email FROM Users WHERE (Phone='" + MD5Login + "' OR Email='" + MD5Login + "')"); result = result.Remove(result.Length - 1); if ((CryptoClass.MD5Hash(OldEmailText) == MD5Login) || (CryptoClass.MD5Hash(OldEmailText) == result)) { return(true); } else { OldEmailComments.Content = "-> не ваш e-mail или его не существует"; } } else { OldEmailComments.Content = "-> некорректный e-mail"; } return(false); }
public static bool ValidateMasterPassword(string password) { if (CryptoClass.MD5Hash(CryptoClass.Base64Encode(password)) == JustTokenClass.MyMasterPassword) { return(true); } return(false); }
private async Task <bool> ValidationOldPhone(string OldPhone) { if (ValidatorClass.IsPhoneNumber(OldPhone) == true) { string MD5Login = DatabaseLogicClass.SQLiteGet("SELECT login FROM logins WHERE authenticated=1"); string result = await DatabaseLogicClass.MySQLGetAsync("SELECT Phone FROM Users WHERE (Phone='" + MD5Login + "' OR Email='" + MD5Login + "')"); result = result.Remove(result.Length - 1); return(CryptoClass.MD5Hash(OldPhone) == result); } return(false); }
private string CheckPhoneLogin(string PhoneString, string PasswordString, bool Login) { string OutPasswordString; if (Login == true) { OutPasswordString = PasswordString; } else { OutPasswordString = CryptoClass.MD5Hash(PasswordString); } if (DatabaseLogicClass.MySQLGet("SELECT Password FROM Users WHERE Phone='" + CryptoClass.MD5Hash(PhoneString) + "'") == OutPasswordString) { return(DatabaseLogicClass.MySQLGet("SELECT Name FROM Users WHERE Phone='" + CryptoClass.MD5Hash(PhoneString) + "'")); } return(""); }
private void EmalTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (CryptoClass.MD5Hash(EmalTextBox.Text) == EmailCode) { EmailComments.Content = "-> верный код"; ValidEmailCode = true; } else { EmailComments.Content = "-> неверный код"; ValidEmailCode = false; } if ((ValidEmailCode == true) && (ValidSMSCode == true)) { FinalConfirmButton.IsEnabled = true; } else { FinalConfirmButton.IsEnabled = false; } }
private async Task <bool> ValidationOldPassword(string OldPassword) { if (ValidatorClass.ValidatePassword(OldPassword) == true) { string MD5Login = DatabaseLogicClass.SQLiteGet("SELECT login FROM logins WHERE authenticated=1"); string result = await DatabaseLogicClass.MySQLGetAsync("SELECT Password FROM Users WHERE (Phone='" + MD5Login + "' OR Email='" + MD5Login + "')"); result = result.Remove(result.Length - 1); if (CryptoClass.MD5Hash(OldPassword) == result) { OldPasswordComments.Content = "-> верный пароль"; return(true); } else { OldPasswordComments.Content = "-> неверный пароль"; } } return(false); }
private async void EmalTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (ValidatorClass.IsValidEmail(EmalTextBox.Text) == true) { string EmailCheckAsync = await DatabaseLogicClass.MySQLGetAsync("SELECT Password FROM Users WHERE Email='" + CryptoClass.MD5Hash(EmalTextBox.Text) + "'"); if (EmailCheckAsync == "") { Emailcomments.Content = "-> валидный e-mail"; EmalTextBox.Foreground = Brushes.Black; ValidEmail = true; } else { Emailcomments.Content = "-> e-mail уже зарегистрирован!"; EmalTextBox.Foreground = Brushes.Red; ValidEmail = false; } } else { Emailcomments.Content = "-> некорректный e-mail"; EmalTextBox.Foreground = Brushes.Red; ValidEmail = false; } NextButton.IsEnabled = (ValidUsername == true) && (ValidEmail == true) && (ValidPhone == true) && (ValidPassword == true) && (ValidMasterPassword == true); }
private async void NextButton_Click(object sender, RoutedEventArgs e) { if ((ValidUsername == true) && (ValidEmail == true) && (ValidPhone == true) && (ValidPassword == true) && (ValidMasterPassword == true)) { string salt = CryptoClass.GetRandomNumber(); //Отправка Email string EmailCode = CryptoClass.GetRandomNumber(); DatabaseLogicClass.SQLiteExecute("INSERT INTO codes(code_source,code) VALUES ('" + CryptoClass.MD5Hash(EmalTextBox.Text + salt) + "','" + CryptoClass.MD5Hash(EmailCode) + "')"); await EmailSenderClass.SendEmailAsync("Ваш код для подтверждения e-mail: " + EmailCode, EmalTextBox.Text); //MessageBox.Show("Email code: " + EmailCode); //Отпрвка SMS string SMSCode = CryptoClass.GetRandomNumber(); DatabaseLogicClass.SQLiteExecute("INSERT INTO codes(code_source,code) VALUES ('" + CryptoClass.MD5Hash(PhoneTextBox.Text + salt) + "','" + CryptoClass.MD5Hash(SMSCode) + "')"); SMSSenderClass ConfirmSMS_obj = new SMSSenderClass(); string[] numbers = new string[] { PhoneTextBox.Text }; var request = new Request { numbers = numbers, text = SMSCode, channel = "DIRECT" }; ConfirmSMS_obj.sms_send(request); //MessageBox.Show("Тук тук халявная SMS: "+SMSCode); ConfirmAllWindow ConfirmWindow_obj = new ConfirmAllWindow(EmalTextBox.Text, PhoneTextBox.Text, CryptoClass.MD5Hash(PasswordBox.Password), salt, UsernameTextBox.Text); ConfirmWindow_obj.Show(); Close(); } }
private async void EmailConfirmButton_Click(object sender, RoutedEventArgs e) { string EmailCode = CryptoClass.GetRandomNumber(); await EmailSenderClass.SendEmailAsync("Ваш код для подтверждения e-mail: " + EmailCode, NewEmailTextBox.Text); DEMKAInputBox demka_obj = new DEMKAInputBox("Ввведите код, отправленный на новый e-mail:"); string InputCode = demka_obj.ShowDialog(); if (InputCode == EmailCode) { await DatabaseLogicClass.MySQLExecuteAsync("UPDATE Users SET Email = '" + CryptoClass.MD5Hash(NewEmailTextBox.Text) + "' WHERE Email='" + CryptoClass.MD5Hash(OldEmailTextBox.Text) + "' "); MessageBox.Show("Успешно обновили email с " + OldEmailTextBox.Text + " на " + NewEmailTextBox.Text); Close(); } else { MessageBox.Show("Код подтвержения '" + InputCode + "' не является действительным"); } }
private async void PhoneConfirmButton_Click(object sender, RoutedEventArgs e) { if ((OldPhoneValidation == true) && (NewPhoneValidation = true)) { string salt = CryptoClass.GetRandomNumber(); string SMSCode = CryptoClass.GetRandomNumber(); DatabaseLogicClass.SQLiteExecute("INSERT INTO codes(code_source,code) VALUES ('" + CryptoClass.MD5Hash(NewPhoneTextBox.Text + salt) + "','" + CryptoClass.MD5Hash(SMSCode) + "')"); SMSSenderClass ConfirmSMS_obj = new SMSSenderClass(); string[] numbers = new string[] { NewPhoneTextBox.Text }; var request = new Request { numbers = numbers, text = SMSCode, channel = "DIRECT" }; ConfirmSMS_obj.sms_send(request); DEMKAInputBox SMSdemka_obj = new DEMKAInputBox("Ввведите код, отправленный на новый номер телефона:"); string InputCode = SMSdemka_obj.ShowDialog(); if (InputCode == SMSCode) { await DatabaseLogicClass.MySQLExecuteAsync("UPDATE Users SET Phone = '" + CryptoClass.MD5Hash(NewPhoneTextBox.Text) + "' WHERE Phone='" + CryptoClass.MD5Hash(OldPhoneTextBox.Text) + "' "); MessageBox.Show("Успешно обновили номер телефона с " + OldPhoneTextBox.Text + " на " + NewPhoneTextBox.Text); } else { MessageBox.Show("Код подтвержения '" + InputCode + "' не является действительным"); } Close(); } }
private void EnterButton_Click(object sender, RoutedEventArgs e) { if ((LoginTextBox.Text != "") && (PasswordBox.Password != "")) { string CheckPhoneLoginString = CheckPhoneLogin(LoginTextBox.Text, PasswordBox.Password, ThisAutoLoginEnabled); string CheckEmailLoginString = CheckEmailLogin(LoginTextBox.Text, PasswordBox.Password, ThisAutoLoginEnabled); if ((CheckPhoneLoginString != "") || (CheckEmailLoginString != "")) { DatabaseLogicClass.SQLiteExecute("UPDATE logins SET authenticated = 0"); DatabaseLogicClass.SQLiteExecute("INSERT INTO logins(login,authenticated) VALUES ('" + CryptoClass.MD5Hash(LoginTextBox.Text) + "',1)"); string outnamestr = (CheckPhoneLoginString != "") ? CheckPhoneLoginString : CheckEmailLoginString; SenderWindow SenderWindow_obj = new SenderWindow(TG_obj, TelegramEnabled, outnamestr); if ((SaveLoginCheckBox.IsChecked == true) && (ThisAutoLoginEnabled == false)) { DatabaseLogicClass.SQLiteExecute("UPDATE savedlogin SET savedbool = 1, login = '******', pass = '******' WHERE id = 1"); } else if (SaveLoginCheckBox.IsChecked == false) { DatabaseLogicClass.SQLiteExecute("UPDATE savedlogin SET savedbool = 0, login = '******', pass = '******' WHERE id = 1"); } MessageBox.Show("Успешная авторизация"); SenderWindow_obj.Show(); Close(); } else { MessageBox.Show("Ошибка аутентификации"); DatabaseLogicClass.SQLiteExecute("UPDATE savedlogin SET savedbool = 0, login = '******', pass = '******' WHERE id = 1"); ThisAutoLoginEnabled = false; LoginTextBox.Text = ""; PasswordBox.Password = ""; } } else { MessageBox.Show("Введите логин пользователя и пароль"); } }
private async void PasswordConfirmButton_Click(object sender, RoutedEventArgs e) { if ((ValidOldPassword == true) && (ValidNewPassword == true) && (ValidNewRepeatPassword == true)) { string MD5Login = DatabaseLogicClass.SQLiteGet("SELECT login FROM logins WHERE authenticated=1"); await DatabaseLogicClass.MySQLExecuteAsync("UPDATE Users SET Password = '******' WHERE (Phone='" + MD5Login + "' OR Email='" + MD5Login + "')"); MessageBox.Show("Успешная смена пароля"); Close(); } }
private void Window_Initialized(object sender, EventArgs e) { FinalConfirmButton.IsEnabled = false; EmailCodeLabel.Content = "Введите код, отправленный на e-mail " + EmailString + ":"; PhoneCodeLabel.Content = "Введите код, отправленный на номер " + SMSString + ":"; EmailCode = DatabaseLogicClass.SQLiteGet("SELECT code FROM codes WHERE code_source='" + CryptoClass.MD5Hash(EmailString + salt) + "'"); SMSCode = DatabaseLogicClass.SQLiteGet("SELECT code FROM codes WHERE code_source='" + CryptoClass.MD5Hash(SMSString + salt) + "'"); }
private async void FinalConfirmButton_Click(object sender, RoutedEventArgs e) { await DatabaseLogicClass.MySQLExecuteAsync("INSERT INTO Users(Phone,Email,Password,Name) VALUES ('" + CryptoClass.MD5Hash(SMSString) + "','" + CryptoClass.MD5Hash(EmailString) + "','" + CryptoClass.MD5Hash(UserPassword) + "','" + CryptoClass.Base64Encode(username) + "')"); MessageBox.Show("Новый пользователь с e-mail " + EmailString + " и телефоном " + SMSString + " был успешно добавлен в систему"); Close(); }
private async void NextButton_Click(object sender, RoutedEventArgs e) { if ((ValidLogin == true) && (ValidMasterPassword == true)) { await DatabaseLogicClass.MySQLExecuteAsync("DELETE FROM Users WHERE (Phone = '" + CryptoClass.MD5Hash(LoginTextBox.Text) + "' OR Email = '" + CryptoClass.MD5Hash(LoginTextBox.Text) + "');"); MessageBox.Show("Пользователь с логином " + LoginTextBox.Text + " был успешно удален из системы"); Close(); } }
private static async Task <bool> CheckUserLogin(string InputLogin) { string ThisResult = await DatabaseLogicClass.MySQLGetAsync("SELECT Password FROM Users WHERE Email='" + CryptoClass.MD5Hash(InputLogin) + "' OR Phone='" + CryptoClass.MD5Hash(InputLogin) + "'"); if (ThisResult != "") { return(true); } return(false); }