Advertisement
Guest User

Untitled

a guest
Apr 10th, 2012
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Application level Controller
  4.  *
  5.  * This file is application-wide controller file. You can put all
  6.  * application-wide controller-related methods here.
  7.  *
  8.  * PHP 5
  9.  *
  10.  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  11.  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  12.  *
  13.  * Licensed under The MIT License
  14.  * Redistributions of files must retain the above copyright notice.
  15.  *
  16.  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  17.  * @link          http://cakephp.org CakePHP(tm) Project
  18.  * @package       app.Controller
  19.  * @since         CakePHP(tm) v 0.2.9
  20.  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  21.  */
  22.  
  23. App::uses('Controller', 'Controller');
  24.  
  25. /**
  26.  * Application Controller
  27.  *
  28.  * Add your application-wide methods in the class below, your controllers
  29.  * will inherit them.
  30.  *
  31.  * @package       app.Controller
  32.  * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
  33.  */
  34. class AppController extends Controller {
  35.     //...
  36.  
  37.     public $components = array(
  38.         'Session',
  39.         'Auth' => array(
  40.             'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
  41.             'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
  42.             'authorize' => array('Controller') // Added this line
  43.         )
  44.     );
  45.  
  46.     public function isAuthorized($user) {
  47.         // Admin can access every action
  48.         if (isset($user['role']) && $user['role'] === 'admin') {
  49.             return true;
  50.         }
  51.    
  52.         // Default deny
  53.         return false;
  54.     }
  55.  
  56.     public function beforeFilter() {
  57.         $this->Auth->allow('index', 'view');
  58.     }
  59.     //...
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement