Ayuda con Cake please , tengo problemas a la hora de hacer login , he creado un app_controller.php (dentro de la carpeta /app). Haber si alguien me puede decir que hago mal, en realidad no me tira ningún error ,simplemente cuando meto corretamente un usuario que existe con su pass me devuelve a la misma pantalla de login pero sin decir nada.
Código:
<?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;
}
}
?>
He reducido el código por razones obvias y solo pego los controladores que entran en juego además de el index.
users_controller.php
Código:
class 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());
}
}
Se me olvidaba el modelo por si las moscas
user.php
Código:
<?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' => ''
)
);
}
?>
Mil gracias y felices fiestas a tod@s