예제 #1
0
        private async void TwoFactorLoginBtn_Click(object sender, EventArgs e)
        {
            instaApi = User.SessionApiBuilder();
            var twoFactorLogin = await instaApi.TwoFactorLoginAsync(TwoFactorCodeTxt.Text);

            if (twoFactorLogin.Succeeded)
            {
                var panelForm = new PanelForm();
                panelForm.ShowDialog();

                this.Hide();
            }
        }
예제 #2
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            newUser = new User();
            if (Properties.Settings.Default.username != null && Properties.Settings.Default.password != null)
            {
                usernameTxt.Text = Properties.Settings.Default.username;
                passwordTxt.Text = Properties.Settings.Default.password;

                //Attempt to automatically load previous saved session
                if (File.Exists("state.bin"))
                {
                    LoadSavedSession();

                    var panelForm = new PanelForm();
                    panelForm.ShowDialog();

                    this.Hide();
                }
            }
        }
예제 #3
0
        private async void LoginBtn_Click(object sender, EventArgs e)
        {
            if (usernameTxt.Text != "" && passwordTxt.Text != "")
            {
                //Add to default setting if Remember Me checkbox is checked
                if (rememberMeBtn.Checked)
                {
                    Properties.Settings.Default.username = usernameTxt.Text;
                    Properties.Settings.Default.password = passwordTxt.Text;
                    Properties.Settings.Default.Save();
                }

                else
                {
                    Properties.Settings.Default.Reset();
                }

                loginBtn.Enabled = false;
                newUser.Username = usernameTxt.Text;
                newUser.Password = passwordTxt.Text;

                newUser.SetUserSessionData();

                _instaApiInstance = User.SessionApiBuilder();

                if (!_instaApiInstance.IsUserAuthenticated)
                {
                    loginProcessLbl.Text = $"Logging in as {newUser.Username}";

                    var loginResult = await _instaApiInstance.LoginAsync();

                    if (loginResult.Succeeded)
                    {
                        this.Hide();
                        var panelForm = new PanelForm();
                        panelForm.Closed += (s, args) => this.Close();
                        panelForm.Show();
                    }

                    //If 2FA is required
                    else if (loginResult.Value == InstaLoginResult.TwoFactorRequired)
                    {
                        var TwoFactorForm = new TwoFactorForm();
                        TwoFactorForm.ShowDialog();

                        this.Hide();
                    }

                    else
                    {
                        MessageBox.Show(loginResult.Info.Message);
                        loginBtn.Enabled = true;
                    }

                    //Save session
                    if (rememberMeBtn.Checked)
                    {
                        SaveSession();
                    }
                }
            }
            else
            {
                MessageBox.Show("Username/Password field cannot be empty");
            }
        }