예제 #1
0
        public bool ChangeUserPassword(Guid userID, string newPassword)
        {
            if (userID == Guid.Empty)
            {
                throw new ArgumentException("userID is invalid");
            }
            if (string.IsNullOrEmpty(newPassword))
            {
                throw new ArgumentNullException("newPassword");
            }

            try
            {
                User user = _userService.GetUser(userID);
                if (user == null)
                {
                    return(false);
                }

                user.EncryptedPassword = CryptographicUtility.Encrypt(newPassword, user.ID);
                _userService.UpdateUserInformation(user);
                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to ChangeUserPassword with values: userID={0}, newPassword={1}", userID, newPassword);
                return(false);
            }
        }
예제 #2
0
        public User Create(string password)
        {
            User user = new User();

            user.ID                       = GuidUtility.GetNewSequentialGuid();
            user.CreationTime             = DateTime.UtcNow;
            user.LastLogin                = null;
            user.LastWrongPasswordAttempt = null;
            user.UpdateTime               = DateTime.UtcNow;
            user.WrongPasswordAttempt     = 0;
            user.EncryptedPassword        = CryptographicUtility.Encrypt(password, user.ID);
            return(user);
        }