Exemple #1
0
        private void TryToSetupLoginKey()
        {
            string errorMessage = ServerRequest.SetPassword(Universal.SystemMACAddress, this.newPassword);

            if (errorMessage != null)
            {
                VisualizingTools.HideWaitingAnimation();
                MessageBox.Show(errorMessage);
            }
            else
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        this.parent.Controls.Remove(this);
                        VisualizingTools.HideWaitingAnimation();
                    }));
                }
                else
                {
                    this.parent.Controls.Remove(this);
                    VisualizingTools.HideWaitingAnimation();
                }
                if (!this.passwordIsSet)
                {
                    BackendManager.LoginProcessRun();
                }
                else
                {
                    BackendManager.SetChangedPassword(this.newPassword);
                    if (Universal.ParentForm.InvokeRequired)
                    {
                        Universal.ParentForm.Invoke(new Action(() =>
                        {
                            Universal.ParentForm.Controls.Remove(this);
                            ConversationPanel.CurrentDisplayedConversationPanel.Visible = true;
                            SlidebarPanel.MySidebarPanel.Visible = true;
                            MessageBox.Show(Universal.ParentForm, "Password has been sucessfully changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }));
                    }
                    else
                    {
                        Universal.ParentForm.Controls.Remove(this);
                        ConversationPanel.CurrentDisplayedConversationPanel.Visible = true;
                        SlidebarPanel.MySidebarPanel.Visible = true;
                        MessageBox.Show(Universal.ParentForm, "Password has been sucessfully changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Exemple #2
0
        private void EventListener(Object sender, EventArgs e)
        {
            if (sender == this.signUpButton)
            {
                if (this.AllSignupConstraintsOk())
                {
                    VisualizingTools.ShowWaitingAnimation(new Point(this.signUpButton.Left, this.signUpButton.Bottom + 20), new Size(this.signUpButton.Width, this.signUpButton.Height / 2), this);
                    childThreadDB = new System.Threading.Thread(delegate()
                    {
                        JObject signupData        = new JObject();
                        signupData["type"]        = "consumer";
                        signupData["username"]    = this.usernameBox.Text;
                        signupData["email"]       = this.emailBox.Text;
                        signupData["name"]        = Universal.NameValidator(this.nameBox.Text);
                        signupData["mac_address"] = Universal.SystemMACAddress;

                        long?userId = ServerRequest.SignupUser(signupData);

                        if (this.InvokeRequired)
                        {
                            this.Invoke(new Action(() =>
                            {
                                if (userId != null)
                                {
                                    Universal.ParentForm.Controls.Remove(this);
                                    this.Dispose();
                                    VisualizingTools.HideWaitingAnimation();
                                }
                                else
                                {
                                    this.signUpButtonMessage.Text = "Error in connection!";
                                    VisualizingTools.HideWaitingAnimation();
                                }
                            }));
                        }
                        if (userId != null)
                        {
                            BackendManager.LoginProcessRun();
                        }
                    });
                    childThreadDB.Start();
                }
            }
            else if (sender == this.policiesLinkLabel)
            {
                this.policiesLinkLabel.ForeColor = Color.FromArgb(106, 0, 154);
            }
        }
 private void EventListener(object sender, EventArgs ee)
 {
     if (sender == this.verifyButton)
     {
         string errorMessage = "";
         if (verificationCodeTextBox.Text == null || verificationCodeTextBox.Text.Length == 0)
         {
             errorMessage += "Verification Code Field Empty!";
             ShowErrorMessage(errorMessage);
             return;
         }
         VisualizingTools.ShowWaitingAnimation(new Point(this.verifyButton.Left, this.verifyButton.Bottom + 20), new Size(this.verifyButton.Width, this.verifyButton.Height / 2), this);
         BackgroundWorker loaderWorker = new BackgroundWorker();
         loaderWorker.DoWork += (s, e) =>
         {
             try
             {
                 int?status = null;
                 status = ServerRequest.VerifyVerificationCode(verificationCodeTextBox.Text, this.purpose);
                 if (status == 1)        //1 means verification code is verified successfully
                 {
                     this.Invoke(new Action(() =>
                     {
                         VisualizingTools.HideWaitingAnimation();
                         this.Visible = false;
                         this.Dispose();
                         if (this.parent != null)
                         {
                             this.parent.Hide();
                             this.parent.Dispose();
                         }
                     }
                                            ));
                     if (this.purpose == "email_verify")
                     {
                         BackendManager.LoginProcessRun();
                     }
                     else if (this.purpose == "password_reset")
                     {
                         Universal.ParentForm.Invoke(new MethodInvoker(BackendManager.ShowPasswordSetupPanel));
                     }
                 }
                 else
                 {
                     if (status == 2)       //2 means verification code is not valid
                     {
                         errorMessage = "Verification Code is invalid!";
                     }
                     else if (status == 3)   //3 means verification code is expried
                     {
                         errorMessage = "Verification Code is expired!\r\nA new verification code is sent.";
                     }
                     else if (status == 4)   //4 means too many wrong (more than 5) attempts
                     {
                         errorMessage = "Too many unsuccessful attempts!\r\nA new verification code is sent.";
                     }
                     else
                     {
                         errorMessage = "Server connection failed!";
                     }
                     this.Invoke(new Action(() =>
                     {
                         ShowErrorMessage(errorMessage);
                     }
                                            ));
                 }
             }
             catch (Exception ex) { Console.WriteLine("Exception in UserVerificationPanel.cs = > " + ex.Message); }
         };
         loaderWorker.RunWorkerAsync();
         loaderWorker.RunWorkerCompleted += (s, e) => { loaderWorker.Dispose(); };
     }
     else if (sender == this.backButton)
     {
         if (this.parent != null)
         {
             this.parent.Visible = true;
         }
         else
         {
             ServerRequest.DeleteConsumerAccount(Universal.SystemMACAddress, "");
             BackendManager.Logout();
         }
         this.Dispose();
     }
 }