Código:
He reducido el código por razones obvias y solo pego los controladores que entran en juego además de el index.<?php class AppController extends Controller { var $components = array('Auth'); function beforeFilter() { $this->Auth->userModel = 'User'; // $this->Auth->loginAction = array( 'controller' => 'users', 'action' => 'index'); $this->Auth->loginRedirect = array ('controller' =>'users','action' => 'index'); $this->Auth->logoutRedirect = array ('controller' =>'users','action' => 'index'); $this->Auth->allow('index','login'); $this->Auth->loginError = "No, you fool! That's not the right password!"; $this->Auth->authError = "Acceso no autorizado."; //$this->Auth->allow('*'); $this->Auth->authorize='controller'; //$this->Auth->userScope = array ('User.confirmed' => '1'); $this->set('loggedIn',$this->Auth->user('id')); } function isAuthorized() { return true; } } ?>
users_controller.php
Código:
Se me olvidaba el modelo por si las moscasclass UsersController extends AppController { var $name = 'Users'; var $helpers = array('Html', 'Form'); function index() { $this->User->recursive = 0; $this->set('users', $this->paginate()); } function login() { } function logout() { $this->Session->setFlash('Logout'); $this->redirect($this->Auth->Logout()); } }
user.php
Código:
Mil gracias y felices fiestas a tod@s <?php class User extends AppModel { var $name = 'User'; var $validate = array( 'name' => array('notempty'), 'surname' => array('notempty'), 'username' => array('notempty'), 'password' => array('notempty') ); //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasMany = array( 'Cliente' => array( 'className' => 'Cliente', 'foreignKey' => 'user_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ) ); } ?>