Cjax Framework


Custom Auth and Routing


Since 5.0RC3 the ajax framework allows for custom authentication and custom routing without making changes to the core files.

There is a file: cjax/auth.default.php, in this file there is a further information and framework functionality to create custom validation and routes. For changes to take effect you must rename file auth.default.php to auth.php.

Auth and Routing

File auth.php has a class name "AjaxAuth", in this class there are two methods, one of them is "validation" - triggers at validation before the ajax request is finished and allows you to write your own custom validation code. The other function is "intercept" - provides you with a section where you can create your custom code to route ajax requests to other parts of your application.

Note: If a controller name is the same name as a Cjax plugin, the request will be routed to that controller plugin's directory.

Auth

Returning true indicates that the session is valid. If your return false the request will not proceed and will present an error.
PHP
<?php 

function validate($controller null$function null$args = array())
{
    return 
true;
}
?>

Routing

Ajax Routes are specially needed if your application supports plugins or addons, then these addons may also have full access to the ajax framework and feed ajax requests through your custom route.
The intercept function gives you space to write your own custom routes. Returning "true" in the intercept function would tell the framework not to persue the request any longer and indicates that your route has taken lead of the request. Returning false would give back the control to the framework and continue the request as it normally would.

Examples

PHP
<?php 

function intercept($controller null$function null $args = array(), $requestObj null)
{
    return 
false;
}
?>

Previous Topic:  Previous Class    ·   Top of Page   ·   Demos Home   ·  

CodeIgniter  ·  Copyright © 2006 - 2012  ·  Cjax