예제 #1
0
        private void TxtUsernameKeyDown(object sender, KeyEventArgs e)
        {
            // if this is a debugging session login automattically
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // this has to be removed after development
                if (e.Control && e.Alt)
                {
                    if (txtUsername.Text == "")
                    {
                        txtUsername.Text = "su";
                    }
                    UserInformation userInfo = null;

                    if (BLL.Settings.UseNewUserManagement)
                    {
                        userInfo = Auth.Authenticate(txtUsername.Text);
                        if (userInfo == null)
                        {
                            //errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = " + username));
                            //return false;
                        }
                        Thread.CurrentPrincipal = SecurityPrincipal.CreateSecurityPrincipal(userInfo);
                    }

                    User usr = new User();
                    usr.Where.UserName.Value = txtUsername.Text;
                    usr.Query.Load();
                    LogUserIn(usr);
                }
            }
        }
예제 #2
0
        public static bool Login(string username, string password)
        {
            var userInfo = Auth.Authenticate(username, password);

            if (userInfo == null)
            {
                errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = "******"Login Window", "Successful Login");
            return(true);
        }
예제 #3
0
        private void BtnLoginClick(object sender, EventArgs e)
        {
            UserInformation userInfo = null;

            try
            {
                if (BLL.Settings.UseNewUserManagement)
                {
                    userInfo = Auth.Authenticate(txtUsername.Text, txtPassword.Text);
                    if (userInfo == null)
                    {
                        //errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = "******"", "", true, txtUsername.Text, Program.HCMISVersionString);
                    if (XtraMessageBox.Show(@"Invalid Username or Password!", @"Login Failed", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop) == DialogResult.Cancel)
                    {
                        Application.Exit();
                    }
                    else
                    {
                    }
                }
            }
            catch
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    //ConnectionStringManager.ConnectionStringManager connMgr =
                    //    new ConnectionStringManager.ConnectionStringManager(Program.RegKey,
                    //                                                        Program.PrevConnectionStringKey);
                    //connMgr.ShowDialog();
                }
                else
                {
                    XtraMessageBox.Show("Network error.  Please make sure your network connection is working.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // Clear the login form
            txtPassword.Text = "";
            txtUsername.Text = "";
            txtUsername.Focus();
        }