Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return to last URL entered after successfull login in Yii

Tags:

php

yii

I have function login on its successful function control goes to dashboard/index. Suppose a user enter leads/index the page come back to login due to access rules defined, i just want that after successful login control goes to last URL entered i.e. leads/index.

like image 709
Mohit Bhansali Avatar asked Apr 22 '13 12:04

Mohit Bhansali


1 Answers

... Controller extends CController (){
...
public function init() {

   if($this->isValidForRedirectRequest(Yii::app()->request)){
       Yii::app()->user->returnUrl = Yii::app()->request->requestUri;
   }
}
...

public function isValidForRedirectRequest(){
   /*something validations of request, like isAjax or other */
}
}...




... LoginController()...{

if($authIdentity->authenticate()) $this->redirect(Yii::app()->user->returnUrl);
...

}
like image 63
yawa yawa Avatar answered Sep 19 '22 10:09

yawa yawa