Login Check And Redirect

Hi,

I am new to yii, i am trying to login and then redirect user to dashboard page. But i also wanted to check if the user is logged in or not.

Here is my code, login works good and now i want to redirect user to "/site/index" on this page i also want to make sure user is logged in. Please help me.

thanks

Here is my code:




if(!$this->hasErrors())

		{

			$identity=new UserIdentity($this->email,$this->password);

			

			$identity->authenticate();

			switch($identity->errorCode)

			{

				case UserIdentity::ERROR_NONE:

					Yii::app()->user->login($identity);

					break;

				case UserIdentity::ERROR_USERNAME_INVALID:

					$this->addError('email','Email address is incorrect.');

					break;

				default: // UserIdentity::ERROR_PASSWORD_INVALID

					$this->addError('password','Password is incorrect.');

					break;

			}

		}