Set eventhandler to the config

I work with the user module yii-user.

There I need an event afterLogin().

Thats my controller code:




	/**

	 * Displays the login page

	 */

	public function actionLogin()

	{

		if (Yii::app()->user->isGuest) {

			$model=new UserLogin;

			

			$this->beforeLogin();


			if($this->disabledEmailAddress)

			  $model->username=$this->disabledEmailAddress;

			

			// collect user input data

			if(isset($_POST['UserLogin']))

			{

				$model->attributes=$_POST['UserLogin'];

				// validate user input and redirect to previous page if valid

				if($model->validate()) {

					$this->lastViset();

					$this->afterLogin();

					$this->redirect(Yii::app()->user->returnUrl);

				}

			}

			// display the login form

			$this->render('/user/login',array('model'=>$model));

		} else

			$this->redirect(Yii::app()->controller->module->returnUrl);

	}




Here are my event code:




/**

	 * This function raises the onAfterLogin event

	 * @param event

	 */

  public function onAfterLogin($event) {

		$this->raiseEvent('onAfterLogin', $event);

	}




 /**

	 * This method is invoked from loginController action login

	 * @param event

	 */

  protected function afterLogin() {

    //Attach the eventhandler

		$this->onAfterLogin=array('Ad', 'handleAfterLogin');

    $this->onAfterLogin(new CEvent($this));

	}




This worked how it should, but I try to attach the eventhandler in my config file but this doesn’t work.

How can I do this?