Exemplo n.º 1
0
        private void Authenticate()
        {
            string username = txtUserName.Text;

            if (string.IsNullOrEmpty(username))
            {
                MessageBox.Show("Type a username.");
            }
            else
            {
                User   user     = _wexflowServiceClient.GetUser(username);
                string password = GetMd5(txtPassword.Text);

                if (user == null)
                {
                    MessageBox.Show("The user " + txtUserName.Text + " does not exist.");
                }
                else
                {
                    if (user.Password == password)
                    {
                        Form1 form1 = new Form1();
                        form1.Show();
                        Hide();
                    }
                    else
                    {
                        MessageBox.Show("The password is incorrect.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void Authenticate()
        {
            try
            {
                string username = txtUserName.Text;
                if (string.IsNullOrEmpty(username))
                {
                    MessageBox.Show("Type a username.");
                }
                else
                {
                    string password = txtPassword.Text;
                    User   user     = _wexflowServiceClient.GetUser(username, password, username);

                    if (user == null)
                    {
                        MessageBox.Show("The user " + txtUserName.Text + " does not exist.");
                    }
                    else
                    {
                        if (user.UserProfile == UserProfile.Restricted)
                        {
                            MessageBox.Show("You do not have enough rights to access Wexflow Manager.");
                        }
                        else
                        {
                            if (user.Password == GetMd5(password))
                            {
                                Username = user.Username;
                                Password = password;

                                Manager manager = new Manager();
                                manager.Show();
                                Hide();
                            }
                            else
                            {
                                MessageBox.Show("The password is incorrect.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show(@"An error occured during the authentication.", "Wexflow", MessageBoxButtons.OK);
            }
        }