php - yii2 login page redirection looping with cancelled status -
after spending many days, trying experts. stuck login redirection in yii2 application in chrome browser,
this controller class,
class invitationscontroller extends controller { public function beforeaction($action) { $array=array('index','imageupload','template','category','subcategory','slug','chooseanotherdesign'); if(!in_array($action->id, $array)) { if (\yii::$app->getuser()->isguest && \yii::$app->getrequest()->url !== url::to(\yii::$app->getuser()->loginurl) ) { \yii::$app->getresponse()->redirect(\yii::$app->getuser()->loginurl,false); } } return parent::beforeaction($action); } public function actiongenerateevent(){ $redirecturl=""; if(yii::$app->request->post()){ unset(yii::$app->session['copyinvitation']); unset(yii::$app->session['eventform']); yii::$app->session['eventform']=yii::$app->request->post(); } if (!yii::$app->user->isguest) { $eventid=$this->invitation->savecontinue(yii::$app->session['eventform']); $eventdata=$this->invitation->geteventbyid($eventid); $refurl=yii::$app->session['eventform']['refererurl']; $aa['events']=$eventdata; $aa['refererurl']=$refurl; yii::$app->session['eventform']=$aa; $redirecturl = yii::$app->urlmanager->createabsoluteurl(['invitations/event/'.$eventdata['event_token']]); return $this->redirect($redirecturl); } } }
my workflow step1: submitting formdata controller xx-action step2: if user login proceed further action else trying store values in session redirecting page login
step 3: after successful login return same xx-action
this workflow working fine in firefox chrome it's making infinitive loop not going through login page. please refer attached screenshot
please me solve issue.
i can't infere how calling actiongenerateevent()
seems have error there:
$redirecturl=""; //empty ... return $this->redirect($redirecturl); //still empty
since not setting $redirecturl
, redirect
redirecting current (same) url again , again, causing loop.
this function used redirecturl()
method: url::to(). docs says:
an empty string: requested url returned;
Comments
Post a Comment