05.20 php saved
paulherron
Tags add more
AuthComponent, auth, authorize, deny and simple  
Note
paulherron did not leave a note
  1. // Code for your AppController. $this->Auth->userScope() is used to say that only the user with the username of 'admin' should be able to log in.
  2.  
  3. <?php
  4. class AppController extends Controller
  5. {
  6.  
  7.     var $components = array('Auth');
  8.    
  9.     function beforeFilter() {
  10.         $this->Auth->authorize = 'controller';
  11.         $this->Auth->userScope = array('User.username = "admin"');
  12.     }
  13.    
  14.     function isAuthorized() {
  15.         return true;
  16.     }
  17.    
  18. }
  19. ?>
  20.  
  21.  
  22. // Then, in the relevant controllers, use $this->Auth->deny() to declare the actions that require a login.
  23.  
  24. <?php
  25. class ArticlesController extends AppController {
  26.  
  27.     function beforeFilter() {
  28.         $this->Auth->deny('admin_index');
  29.         parent::beforeFilter();
  30.     }
  31.    
  32. }
  33. ?>
Parsed in 0.027 seconds, using GeSHi 1.0.7.14

Modify this Paste