verifyAccount() public method

Checks if the account really exists
public verifyAccount ( string CountryCode, string Phonenumber, string Password ) : bool
CountryCode string The country code with a + eg: +31
Phonenumber string The phone number without the country code eg: 0624115307
Password string The password of the whatsapp account
return bool
Esempio n. 1
0
        /// <summary>
        /// Handles logging in, supposed to run in a seperated thread
        /// </summary>
        private void login()
        {
            if (ComboBox_Login.SelectedItem == null)
            {
                return;
            }
            WhatsappAccount Account = (WhatsappAccount)ComboBox_Login.SelectedItem;

            // Verify Account
            WhatsAppHelper Helper = new WhatsAppHelper();
            bool           Result = Helper.verifyAccount(Account.CountryCode, Account.Phonenumber, Account.Password);

            if (Result == true)
            {
                // Account is valid, show main form
                Form_Main frmMain = new Form_Main(Account);
                this.Close();
                frmMain.ShowDialog();
            }
            else
            {
                DialogResult Re = MessageBox.Show("The selected acocunt does not appear to be working, do you want to remove it?", "Error: Account not working", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (Re == DialogResult.Yes)
                {
                    // Delete account
                    Database.Query("DELETE FROM accounts WHERE phonenumber='" + Account.Phonenumber + "'");

                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text    = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
                else
                {
                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text    = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Verifies the new account that is about to be added, this method is supposed to run
        /// in a seperated thread.
        /// </summary>
        private void verifyAccount()
        {
            WhatsAppHelper Helper = new WhatsAppHelper();

            WhatsAppHelper.DeviceOS OS = WhatsAppHelper.DeviceOS.Other;
            if (ComboBox_DeviceOS.Text == "iOS")
            {
                OS = WhatsAppHelper.DeviceOS.iOS;
            }
            string Password = Helper.generatePassword(TextBox_ImeiMac.Text, OS);
            bool   Result   = Helper.verifyAccount(ComboBox_CountryCode.Text, TextBox_Phonenumber.Text, Password);

            if (Result == true)
            {
                // Account exists, insert into database
                Dictionary <string, string> Values = new Dictionary <string, string>();
                Values.Add("countrycode", ComboBox_CountryCode.Text);
                Values.Add("phonenumber", TextBox_Phonenumber.Text);
                Values.Add("password", Password);
                Database.Insert("accounts", Values);

                // Resize form
                CollapseForm();

                // Update combobox
                updateAccounts();

                // Set phonenumber as selected
                ComboBox_Login.Text = TextBox_Phonenumber.Text;

                // Clear all fields
                TextBox_ImeiMac.Text     = "";
                TextBox_Phonenumber.Text = "";
                ComboBox_DeviceOS.Text   = "Android";
                Label_ImeiMac.Text       = "International Mobile Equipment Identity (IMEI):";

                // Re-enable controls
                SetControlsEnabled(true);
                Label_Status.Visible = false;
            }
            else
            {
                // Account does not exists
                MessageBox.Show("Sorry, your account does not exists or you have given invalid information. Please re-check all field.", "Error: Account does not exists", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        /// <summary>
        /// Verifies the new account that is about to be added, this method is supposed to run
        /// in a seperated thread.
        /// </summary>
        private void verifyAccount()
        {
            WhatsAppHelper Helper = new WhatsAppHelper();
            WhatsAppHelper.DeviceOS OS = WhatsAppHelper.DeviceOS.Other;
            if (ComboBox_DeviceOS.Text == "iOS") OS = WhatsAppHelper.DeviceOS.iOS;
            string Password = Helper.generatePassword(TextBox_ImeiMac.Text, OS);
            bool Result = Helper.verifyAccount(ComboBox_CountryCode.Text, TextBox_Phonenumber.Text, Password);
            if (Result == true)
            {
                // Account exists, insert into database
                Dictionary<string, string> Values = new Dictionary<string,string>();
                Values.Add("countrycode", ComboBox_CountryCode.Text);
                Values.Add("phonenumber", TextBox_Phonenumber.Text);
                Values.Add("password", Password);
                Database.Insert("accounts", Values);

                // Resize form
                CollapseForm();

                // Update combobox
                updateAccounts();

                // Set phonenumber as selected
                ComboBox_Login.Text = TextBox_Phonenumber.Text;

                // Clear all fields
                TextBox_ImeiMac.Text = "";
                TextBox_Phonenumber.Text = "";
                ComboBox_DeviceOS.Text = "Android";
                Label_ImeiMac.Text = "International Mobile Equipment Identity (IMEI):";

                // Re-enable controls
                SetControlsEnabled(true);
                Label_Status.Visible = false;
            }
            else
            {
                // Account does not exists
                MessageBox.Show("Sorry, your account does not exists or you have given invalid information. Please re-check all field.", "Error: Account does not exists", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        /// <summary>
        /// Handles logging in, supposed to run in a seperated thread
        /// </summary>
        private void login()
        {
            if (ComboBox_Login.SelectedItem == null)
                return;
            WhatsappAccount Account = (WhatsappAccount)ComboBox_Login.SelectedItem;

            // Verify Account
            WhatsAppHelper Helper = new WhatsAppHelper();
            bool Result = Helper.verifyAccount(Account.CountryCode, Account.Phonenumber, Account.Password);
            if (Result == true)
            {
                // Account is valid, show main form
                Form_Main frmMain = new Form_Main(Account);
                this.Close();
                frmMain.ShowDialog();
            }
            else
            {
                DialogResult Re = MessageBox.Show("The selected acocunt does not appear to be working, do you want to remove it?", "Error: Account not working", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (Re == DialogResult.Yes)
                {
                    // Delete account
                    Database.Query("DELETE FROM accounts WHERE phonenumber='" + Account.Phonenumber + "'");

                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
                else
                {
                    // Reload combobox
                    updateAccounts();

                    // Hide status label
                    Label_Status.Visible = false;
                    Label_Status.Text = "Please wait while we verify your account.";

                    // Enable controls
                    SetControlsEnabled(true);
                }
            }
        }