示例#1
0
        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);
        }
示例#2
0
 public SenderWindow(TelegramClass recieved, bool TelegramEnabled, string LoginedName)
 {
     TelegramEnabledForm = TelegramEnabled;
     TG_obj           = recieved;
     LocalLoginedName = "Авторизация: " + CryptoClass.Base64Decode(LoginedName);
     InitializeComponent();
 }
示例#3
0
        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();
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
 public static bool ValidateMasterPassword(string password)
 {
     if (CryptoClass.MD5Hash(CryptoClass.Base64Encode(password)) == JustTokenClass.MyMasterPassword)
     {
         return(true);
     }
     return(false);
 }
示例#6
0
        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);
        }
示例#7
0
        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("");
        }
示例#8
0
        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 + "' не является действительным");
            }
        }
示例#9
0
        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;
            }
        }
示例#10
0
        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);
        }
示例#11
0
        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("Введите логин пользователя и пароль");
            }
        }
示例#12
0
        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();
            }
        }
示例#13
0
        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) + "'");
        }
示例#14
0
        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();
        }
示例#15
0
        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();
            }
        }
示例#16
0
        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);
        }
示例#17
0
        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);
        }