Hi all,
When putting $activity->save(); as shown below before $this->redirect(Yii::app()->homeUrl);, the site breaks when log in details are incorrect.
However, $activity->save(); works just fine in other actions such as actionLogout() below.
What went wrong?
Thanks,
Michael
public function actionLogin()
	{
		/* log in */
		
		$model=new LoginForm;
		// if it is ajax validation request
		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}
		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the previous page if valid
			if($model->validate() && $model->login())										
				
				
				// log
				$activity = new Activity;
				$activity->userId = 1;				
				//$activity->userId = Yii::app()->user->id;
				$activity->name = "logging in";
				// This breaks the site when log in details are wrong
				$activity->save();
				
				$this->redirect(Yii::app()->homeUrl);
								
				
				
		}
		// display the login form
		$this->render('login',array('model'=>$model));
	}
	/**
	 * Logs out the current user and redirect to homepage.
	 */
	public function actionLogout()
	{
		
		// log
		$activity = new Activity;
		$activity->userId = Yii::app()->user->id;
		$activity->name = "logging out";
		$activity->save();	
		
		
		Yii::app()->user->logout();					
		
		$this->redirect(Yii::app()->homeUrl);
	}