yii-user login return url

I have some pages where login is required for example ‘/shop/product/create’.

Here is the code from the yi-user LoginController




if($model->validate()) {

  $this->lastViset();

  if (strpos(Yii::app()->user->returnUrl,'/index.php')!==false)

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

  else

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

  }



My returnUrl variable in UserModule is ‘user/profile’.

When I go to the site shop/product/create I see the login form. This is ok.

But after login I redirected always to user/profile but I want that I redirected to shop/product/create.

The problem is the following code

if (strpos(Yii::app()->user->returnUrl,’/index.php’)!==false)

because normally the user->returnUrl is application/index.php.

I think it were better when we ask about the homeUrl and only when we come from the homeUrl we should redirected to the module->returnUrl

How can I solve this without hacking the yii-user core.

just modify the yii-user LoginController code




if($model->validate()) {

  $this->lastViset();

  if (strpos(Yii::app()->user->returnUrl,'/index.php')!==false)

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

  else

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

  }



to




if($model->validate()) {

  $this->lastViset();

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

  }



because in the loginRequired() function in CWebUser class, set returnUrl to the request url.




if(!$request->getIsAjaxRequest())

    $this->setReturnUrl($request->getUrl());




Thank you.

I have done it so.

This will return me to the page I am in when I click the link, not the page you want to go.

Any idea?