Yii Framework Forum: yii-user login return url - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

yii-user login return url After Login always the module returnUrl Rate Topic: -----

#1 User is offline   klaus66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 15-October 11
  • Location:Germany

Posted 03 January 2012 - 12:44 PM

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.
0

#2 User is offline   gumreal 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 27-January 12

Posted 27 January 2012 - 10:46 AM

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());


0

#3 User is offline   klaus66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 15-October 11
  • Location:Germany

Posted 25 April 2012 - 09:31 AM

Thank you.

I have done it so.
0

#4 User is offline   rosoft2001 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 19-April 12

Posted 20 May 2012 - 09:03 PM

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

Any idea?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users