/// <summary>Validate a set of user credentials, and return the user obejct if valid</summary>
        public AuthenticationResult AuthenticateUser(string emailAddress, string password, out User user)
        {
            user = null;

            var result = AuthenticateUser(emailAddress, password);

            if (result == AuthenticationResult.Success)
                user = userService.GetByEmail(emailAddress);

            return result;
        }
        /// <summary>Replace properties on source with those from target</summary>
        public static void ApplyValues(this User source, User newValues)
        {
            if (source == null || newValues == null)
            {
                return;
            }
            source.EmailAddress = newValues.EmailAddress;

            // check if a new password is provided
            if (newValues.Password != null)
            {
                // create new salt key for each new password
                source.Salt = SecurityExtensions.GenerateSalt();
                source.Password = newValues.Password.Hash(source.Salt);
            }
        }