Beispiel #1
0
        public void LogIn(string username, string password)
        {
            if (String.IsNullOrWhiteSpace(username))
            {
                throw new Exception("No user name supplied");
            }

            if (String.Equals(username, _defaultUser.Name))
            {
                CurrentUser = _defaultUser;
                UpdateCurrentUser.SafeInvoke(this, new CurrentUserEventArgs(CurrentUser));
                return;
            }

            if (String.IsNullOrWhiteSpace(password))
            {
                throw new Exception("No user password supplied");
            }

            User user = null;

            if (user == null && username == "HSTME" && password == "meengineering")
            {
                user         = new User("HSTME", "meengineering", UserLevel.Engineer, true);
                user.EmpName = "Bypass login";
            }

            if (user == null)
            {
                throw new Exception("No user exists by this name");
            }

            if (!String.Equals(user.Password, password))
            {
                throw new Exception("User password is invalid");
            }

            if (user.Level == UserLevel.Administrator && HSTMachine.Workcell.Process.IsRunState)
            {
                Notify.PopUp("Invalid User Login", "User with Administrator level cannot login while system is running.", "", "OK");
                return;
            }
            CurrentUser = user;

            UpdateCurrentUser.SafeInvoke(this, new CurrentUserEventArgs(CurrentUser));
        }
        public void LogIn(string username, string password)
        {
            if (String.IsNullOrWhiteSpace(username))
            {
                throw new Exception("No user name supplied");
            }

            if (String.Equals(username, _defaultUser.Name))
            {
                CurrentUser = _defaultUser;
                UpdateCurrentUser.SafeInvoke(this, new CurrentUserEventArgs(CurrentUser));
                return;
            }

            if (String.IsNullOrWhiteSpace(password))
            {
                throw new Exception("No user password supplied");
            }

            User user = null;

            if (String.Equals(username, _adminUser.Name))
            {
                user = _adminUser;
            }
            else
            {
                user = Users[username];
            }

            if (user == null)
            {
                throw new Exception("No user exists by this name");
            }

            if (!String.Equals(user.Password, password))
            {
                throw new Exception("User password is invalid");
            }

            CurrentUser = user;

            UpdateCurrentUser.SafeInvoke(this, new CurrentUserEventArgs(CurrentUser));
        }