public HorebUser Insert(string username, string password)
        {
            HorebUser user = new HorebUser(username);

            _userCollection.Add(user);
            return(user);
        }
예제 #2
0
 private void GivenAUser()
 {
     _user                   = _userService.CreateUser("ArturoD93", "password123", out CreateUserStatus status);
     _user.CreatedById       = "Administrator26";
     _user.LastestUpdateById = "AnotherAdmin78";
     _user.Email             = "*****@*****.**";
     _user.PhoneNumber       = "8587744185";
     _user.IsActive          = true;
     _user.LastActivityDate  = DateTime.Now;
     _userService.UpdateUser(_user);
 }
예제 #3
0
        /// <summary>Updates a user to the Horeb data source.</summary>
        /// <param name="user">The user (HorebUser) to update.</param>
        /// <exception cref="T:System.ArgumentNullException">
        public void UpdateUser(HorebUser user)
        {
            if (user == null || user == HorebUser.Empty)
            {
                throw new ArgumentNullException(nameof(user));
            }
            string email = user.Email;

            SecureUtility.CheckParameter(ref email, true, true, true, 256, nameof(email));
            user.Email = email;
            _userDao.Update(user);
        }
        public HorebUser FindByEmail(string email)
        {
            HorebUser user = HorebUser.Empty;

            foreach (HorebUser currentUser in _userCollection)
            {
                if (currentUser.Email.Equals(email.Trim(), StringComparison.CurrentCultureIgnoreCase))
                {
                    user = currentUser;
                }
            }
            return(user);
        }
        public HorebUser Find(string userName)
        {
            HorebUser user = HorebUser.Empty;

            foreach (HorebUser currentUser in _userCollection)
            {
                if (currentUser.Id.Equals(userName.Trim(), StringComparison.CurrentCultureIgnoreCase))
                {
                    user = currentUser;
                }
            }
            return(user);
        }
예제 #6
0
        /// <summary>Gets the information from the data source and updates the last-activity date/time stamp for the current logged-on Horeb user.</summary>
        /// <returns>A <see cref="T:Horeb.Domain.UserModule.HorebUser" /> object representing the current logged-on user.</returns>
        /// <exception cref="T:System.ArgumentException">No Horeb user is currently logged in.</exception>
        public HorebUser GetUser()
        {
            HorebUser user = HorebUser.Empty;

            if (IsUserLoggedIn())
            {
                user = _userDao.Find(_applicationState.CurrentLoggedInUser);
                _userDao.UpdateUserActivity(user.Id);
            }
            else
            {
                throw new ArgumentException("No Horeb user is currently logged in.");
            }
            return(user);
        }
예제 #7
0
        /// <summary>Logs in a the given Horeb user and updates the last-activity date/time stamp if sucessful.</summary>
        /// <param name="username">The user name to log-in.</param>
        /// <param name="logInStatus">The status of the log-in action.</param>
        /// <returns> True if the user was logged on successfully. False otherwise.</returns>
        /// <exception cref="T:System.ArgumentNullException">
        public bool Login(string username, out LoginStatus logInStatus)
        {
            SecureUtility.CheckParameter(ref username, true, false, true, 256, nameof(username));
            if (!_userDao.DoesUserExist(username))
            {
                logInStatus = LoginStatus.UserDoesNotExist;
                return(false);
            }
            HorebUser user = _userDao.Find(username);

            _userDao.UpdateUserActivity(user.Id);
            _applicationStateSetter.SetCurrentLoggedInUser(username);
            logInStatus = LoginStatus.LoggedIn;
            return(true);
        }
        public MockUserDao()
        {
            _userCollection = new HorebUserCollection();
            HorebUser userOne = Insert("ricardoDuran1", "easyPass123");

            userOne.CreatedById = "rootUser";
            userOne.Email       = "*****@*****.**";
            userOne.PhoneNumber = "6197201905";
            Update(userOne);

            HorebUser userTwo = Insert("mockUser9", "anotherEasyPass321");

            userOne.CreatedById = "rootUser";
            userOne.Email       = "*****@*****.**";
            userOne.PhoneNumber = "8585617899";
            Update(userOne);
        }
예제 #9
0
        /// <summary>Logs in a the given Horeb user and updates the last-activity date/time stamp if sucessful.</summary>
        /// <param name="username">The user name (username) to log-in.</param>
        /// <param name="password">The password to match to the user to log-in</param>
        /// <param name="logInStatus">The status of the log-in action.</param>
        /// <returns> True if the user was logged on successfully. False otherwise.</returns>
        /// <exception cref="T:System.ArgumentNullException">
        public bool Login(string username, string password, out LoginStatus logInStatus)
        {
            SecureUtility.CheckParameter(ref username, true, false, true, 256, nameof(username));
            SecureUtility.CheckPasswordParameter(ref password, 15, nameof(username));
            if (_userDao.DoesUserExist(username))
            {
                logInStatus = LoginStatus.UserDoesNotExist;
                return(false);
            }
            HorebUser user = _userDao.Find(username);

            if (!_userDao.FindUserPassword(user.Id).Equals(password))
            {
                logInStatus = LoginStatus.InvalidPassword;
                return(false);
            }
            return(Login(username, out logInStatus));
        }
        public void UpdateUserActivity(string userId)
        {
            HorebUser user         = HorebUser.Empty;
            bool      wasUserFound = false;

            foreach (HorebUser currentUser in _userCollection)
            {
                if (currentUser.Id.Equals(userId))
                {
                    wasUserFound = true;
                    currentUser.LastActivityDate = DateTime.Now;
                    user = currentUser;
                }
            }
            if (wasUserFound)
            {
                Update(user);
            }
        }
 public void Update(HorebUser user)
 {
     _userCollection.Remove(user.Id);
     _userCollection.Add(user);
 }