$this->loadComponent('RequestHandler');
-
+
+ $this->loadComponent('Flash');
+ $this->loadComponent('Auth', [
+ 'authenticate' => [
+ 'Form' => [
+ 'fields' => [
+ 'username' => 'username',
+ 'password' => 'password'
+ ]
+ ]
+ ],
+ 'loginAction' => [
+ 'controller' => 'Users',
+ 'action' => 'login'
+ ],
+ 'loginRedirect' => [
+ 'controller' => 'Softwares',
+ 'action' => 'index'
+ ],
+ 'logoutRedirect' => [
+ 'controller' => 'Pages',
+ 'action' => 'display',
+ 'home'
+ ]
+ ]);
+
+ //Autorise l'action display pour que notre controller de pages
+ // continue de fonctionner.
+ $this->Auth->allow(['display']);
+
+ }
+
+ public function isAuthorized($user)
+ {
+ // Admin peuvent accéder à chaque action
+ if (isset($user['role']) && ($user['role'] === 'admin')) {
+ return true;
+ }
+
+ // Par défaut refuser
+ return false;
}
*/
public function beforeRender(Event $event)
{
- if (!array_key_exists('_serialize', $this->viewVars) &&
- in_array($this->response->type(), ['application/json', 'application/xml'])
- ) {
- $this->RequestHandler->renderAs($this, 'json');
- $this->set('_serialize', true);
- }
- $this->RequestHandler->renderAs($this, 'json');
-
- $this->set('_serialize', true);
+// if (!array_key_exists('_serialize', $this->viewVars) &&
+// in_array($this->response->type(), ['application/json', 'application/xml'])
+// ) {
+// $this->RequestHandler->renderAs($this, 'json');
+// $this->set('_serialize', true);
+// }
+// $this->RequestHandler->renderAs($this, 'json');
+//
+// $this->set('_serialize', true);
}
*/
public function beforeFilter(Event $event) {
parent::beforeFilter($event);
-
-
}
}