| 3 | | class AppController extends Controller{ |
| 4 | | |
| 5 | | // necessary, we need to have the othauth component so it can do it's business logic |
| 6 | | public $components = array('othAuth'); // http://www.devmoz.com/blog/ |
| 7 | | |
| 8 | | // html is always needed, othauth helper is not a must, but you can do some cool things with it (see later on) |
| 9 | | public $helpers = array('Html', 'othAuth', 'Javascript', 'Form'); |
| 10 | | |
| 11 | | // tags authorized to inputfilter |
| 12 | | public $tags = array("font", "em", "strong", "div", "img", "p", "br", "hr", "a", "i", "b", "object", "param", "embed"); |
| 13 | | |
| 14 | | // attributes authorized to inputfilter |
| 15 | | public $attr = array("color", "width", "src", "height", "alt", "title", "href", "value", "type", "name", "align"); |
| 16 | | |
| 17 | | // these are the global restrictions, they are very important. |
| 18 | | //all the permissions defined above are weighted against these restrictions to calculate the total allow or deny for a specific request. |
| 19 | | public $othAuthRestrictions = array('admin_add','admin_edit','admin_delete', 'admin_listing', 'admin_start'); |
| 20 | | |
| 21 | | public function beforeFilter() { |
| 22 | | |
| 23 | | $auth_conf = array( |
| 24 | | 'mode' => 'oth', |
| 25 | | 'login_page' => '/users/login', |
| 26 | | 'logout_page' => '/users/logout', |
| 27 | | 'access_page' => '/news/view', |
| 28 | | 'hashkey' => 'mYpERsOn78787ALhaSHkeY', |
| 29 | | 'noaccess_page' => '/users/noaccess', |
| 30 | | 'strict_gid_check' => true); |
| 31 | | |
| 32 | | $this->othAuth->controller = &$this; // controlleret |
| 33 | | $this->othAuth->init($auth_conf); |
| 34 | | $this->othAuth->check(); |
| 35 | | |
| 36 | | } |
| 37 | | |
| 38 | | public function msgFlash($msg, $to) |
| 39 | | { |
| 40 | | $this->Session->setFlash($msg); // http://manual.cakephp.org/chapter/session |
| 41 | | |
| 42 | | $this->redirect($to); |
| 43 | | |
| 44 | | exit; |
| 45 | | } |
| | 4 | class AppController extends Controller { |
| | 5 | |
| | 6 | public $components = array('Auth', 'Cookie'); |
| | 7 | |
| | 8 | public $helpers = array('Html', 'Form', 'Session'); |
| | 9 | |
| | 10 | public function beforeFilter() |
| | 11 | { |
| | 12 | $this->Auth->fields = array('username' => 'username', 'password' => 'password'); |
| | 13 | $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); |
| | 14 | $this->Auth->loginRedirect = array('controller' => 'news', 'action' => 'display'); |
| | 15 | $this->Auth->logoutRedirect = '/'; |
| | 16 | $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; |
| | 17 | $this->Auth->authorize = 'controller'; |
| | 18 | $this->Auth->allow( array('display', 'view', 'register') ); |
| | 19 | |
| | 20 | $this->set('cU', $this->Auth->user()); // $cU current user |
| | 21 | } |