Wednesday, October 27, 2010

Modify Auth

What would be the best way to modify the $this->Auth->ajaxLogin = '/elements/users/expired_login';

 

Since all my ajax calls return JSON with a status true or false along with the element.

 if I login, delete my session and then make an ajax call I see the server response of the elements/users/expired_login but nothing shows because my js is looking for true / false status in the JSON response.

 

I have tried a few things like

 

App_controller beforeFilter

 

if ( $this->RequestHandler->isAjax() && !$this->Session->valid()) {

$response = array(

'status' => false,

'message' => ‘not logged in test message .');

                               

                               

                                $this->header( 'Content-Type: application/json' );

                                echo json_encode( $response );

                                exit();

                                               

} else {

$this->Auth->ajaxLogin = '/elements/users/expired_login';

}

 

But it seems to always get stuck on the else{}  part and attempt to return the ajaxLogin element.

 

Any ideas?

 

 

No comments: