title: Redirect to module after login Yii
body: <p>Building a site in yii, where there are 3 types of users.
  In the UserIdentity::authenticate() I set the type of user like this. <code>$this-&gt;setState('role', $user-&gt;role-&gt;id);</code> Depending on this type, i want to redirect to a module belonging to this type of user. To be more specific; if Yii::app()->user->role == 3 I want to redirect to the default page of the module called 'tradesman'.
  This is what I got in SiteController::actionLogin():</p>
  
  <pre><code>/**
   * Displays the login page
   */
  public function actionLogin()
  {
      $model=new LoginForm;
      // if it is ajax validation request
      if(isset($_POST['ajax']) &amp;&amp; $_POST['ajax']==='login-form')
      {
          echo CActiveForm::validate($model);
          Yii::app()-&gt;end();
      }
  
      // collect user input data
      if(isset($_POST['LoginForm']))
      {
          $model-&gt;attributes=$_POST['LoginForm'];
          // validate user input and redirect to the previous page if valid
          if($model-&gt;validate() &amp;&amp; $model-&gt;login()){
              switch(Yii::app()-&gt;user-&gt;role){
                  case 3:
                      $this-&gt;redirect(Yii::app()-&gt;controller-&gt;module-&gt;tradesman);
                      break;
                  default:
                      $this-&gt;redirect(Yii::app()-&gt;user-&gt;returnUrl);
              }
          }
      }
      // display the login form
      $this-&gt;render('login',array('model'=&gt;$model));
  }
  </code></pre>
  
  <p>The redirect to the module doesn't work this way. I'am getting the Php notice 'Trying to get property of non-object'. I've then made a method 'defaultUrl in the TradesmanModule which returns <code>Yii::app()-&gt;createUrl($this-&gt;getId() . '/default/index');</code>. I tried to redirect to <code>Yii::app()-&gt;controller-&gt;module-&gt;defaultUrl</code>, but the result was the same.</p>
  
  <p>I also tried <code>$this-&gt;redirect('tradesman/default/index');</code> &amp; <code>$this-&gt;redirect('application.modules.tradesman');</code> but then i'am getting a 404 error saying 'The system is unable to find the requested action "tradesman".'.</p>
  
  <p>If I am logged in as a user with role 3, and I navigate to the default url of the module, it does work. But how can i redirect?</p>