|
AuthorAuthentication
Instructions for login implementation with Lilblogs Author model
IntroductionLilBlogs has an ability to login and authenticate users via Authors model. ImplementationAuthorizing users with LilBlogs is actually quite simple. All you need is to setup Auth component in AppController class of your application ( /app/app_controller.php ). LilBlogs will use controller authorization to check author permissions on specific blog. If you want to use different type of authorization (acl) you'll have to implement access control by yourself. Sample configuration is shown below: class AppController extends Controller {
var $components = array('Auth');
function beforeFilter() {
// import model Author so Auth component can find it
App::import('Model', 'LilBlogs.Author');
// you can optionally set target location for redirect after login/logout
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
// here comes the most important part
$this->Auth->loginAction = '/lil_blogs/login';
$this->Auth->userModel = 'Author';
$this->Auth->fields = array('username' => 'username', 'password' => 'passwd');
// authorization method (check CakePHP manual) for details
// for 'controller' type there has to be isAuthorized() function somewhere in your controller
// you can add this function right below beforeFilter() - it should return true if user is allowed to access controller/action
$this->Auth->authorize = 'controller';
}
function isAuthorized() {
return true;
}
}
|
Sign in to add a comment