public static function userLogin($data, $loginField='email') {
		if( empty($data[$loginField]) )  {
			static::throwException('invalidLoginID');
		}
		$name = $data[$loginField];
		if( empty($data['password']) )  {
			static::throwException('invalidPassword');
		}
		$password = hashString($data['password']);
		//self::checkForEntry() does not return password and id now.
		
		$user = static::get(array(
// 			'where' => 'name LIKE '.static::formatValue($name),
			'where'		=> static::formatValue($name).' IN ('.implode(',', static::listLoginFields()).')',
			'number'	=> 1,
			'output'	=> SQLAdapter::OBJECT
		));
		if( empty($user) )  {
			static::throwException("invalidLoginID");
		}
		if( isset($user->published) && !$user->published )  {
			static::throwException('forbiddenLogin');
		}
		if( $user->password != $password )  {
			static::throwException('wrongPassword');
		}
		$user->logout();
		$user->login();
		return $user;
	}