Friday, August 31, 2012

Re: Cakephp 1.3 - Detect if Ajax if session expired

We have this is a problem, too. Last Romel's solution sounds pretty good.
I would like though that this can be the default behavior (ex: putting it in AppController::beforeFilter). But I want that all the actions specified by $this->Auth->allow(...) do not to emit the {"login":true}

One option is to call $this->Auth->allow(...) before
parent::beforeFilter() in the derived controllers and having something (?) that tells if the current action is in the allow list.
However an optional solution should be able to work even if parent::beforeFilter() is called before  Auth->allow.

Should not this be a feature of the AuthComponent?

Best,
   Chris


On Fri, Aug 31, 2012 at 6:02 AM, romel javier gomez herrera <bmxquiksilver7185@gmail.com> wrote:
hi 


<?php class AppController extends Controller {

public function beforeFilter(){
if ($this->Auth->User()){
}else{
if($this->params['isAjax']){
// if the session expired
$return['login'] = true;
echo json_encode($return); // responseText: "{"login":true}"
}
}
}
} ?>

Best regards!


2012/8/31 Florin Trifu <florin.catalin.trifu@gmail.com>
Thank you!

This is how I have tried in the first place but it is not working. $this->RequestHandler->isAjax() is null or false, so it will never execute the conditional code.

Best regards!

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 



--
--Everything should be made as simple as possible, but not simpler (Albert Einstein)

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: