demos/phonebook/protected/controllers/SiteController.php
public function beforeWebMethod($service)
	{
		$safeMethods=array(
			'login',
			'getContacts',
		);
		$pattern='/^('.implode('|',$safeMethods).')$/i';
		if(!Yii::app()->user->isGuest || preg_match($pattern,$service->methodName))
			return true;
		else
			throw new CException('Login required.');
	}
public function beforeWebMethod($service)
	{
		$safeMethods=array(
			'login',
			'getContacts',
		);
		$pattern='/^('.implode('|',$safeMethods).')$/i';
		if(!Yii::app()->user->isGuest || preg_match($pattern,$service->methodName))
			return true;
		else
			throw new CException('Login required.');
	}
public function beforeWebMethod ( $ service ) { $ safeMethods = array ( 'login' , 'getContacts' , ) ; $ pattern = '/^(' . implode ( '|' , $ safeMethods ) . ')$/i' ; if ( ! Yii :: app ( ) -> user -> isGuest || preg_match ( $ pattern , $ service -> methodName ) ) return true ; else throw new CException ( 'Login required.' ) ; }
This method is required by IWebServiceProvider.
It makes sure the user is logged in before making changes to data.
@param CWebService the currently requested Web service.
@return boolean whether the remote method should be executed.
This method is required by IWebServiceProvider . It makes sure the user is logged in before making changes to data .