hello, i have a problem with the login redirect i dont no why but when
i write the loginRedirect it not redirect me, just show me the login
page and i want to redirect to another page. i manually inserted the
username and pasword in the database. any help would be great, thanks
NOTE: if some see "Productos" is in spanish.
my code
app_controller
_____________________
<?php
class ProductosController extends AppController {
var $name = 'Productos';
var $helpers = array('Html', 'Form');
var $components = array('Auth');
function index() {
$this->set('productos', $this->paginate());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('No hay productos
agregados.', true));
$this->redirect(array('action'=>'index'));
}
$this->set('producto', $this->Producto->read(null, $id));
}
function add() {
if (!empty($this->data)) {
$this->Producto->create();
if ($this->Producto->save($this->data)) {
$this->Session->setFlash(__('El producto ha
sido agregado',
true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('El producto no ha
sido agregado,
intentelo de nuevo.', true));
}
}
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('No hay productos
agregados', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Producto->save($this->data)) {
$this->Session->setFlash(__('El producto ha
sido editado', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('El producto no ha
sido editado,
intentelo de nuevo.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Producto->read(null, $id);
}
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Error en la identificacion
del
Producto', true));
$this->redirect(array('action'=>'index'));
}
if ($this->Producto->del($id)) {
$this->Session->setFlash(__('Producto eliminado',
true));
$this->redirect(array('action'=>'index'));
}
$this->redirect(array('action'=>'index'));
}
function beforeFilter() {
$this->Auth->userModel = 'User';
$this->Auth->fields = array('username' => 'username',
'password' =>
'password');
$this->Auth->loginAction = array('admin' => false, 'controller'
=>
'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'users',
'action'
=> 'index');
$this->loginError = 'Username o Password incorrectos';
}
}
?>
users_controller
_________________
<?php
class UsersController extends AppController
{
var $name = "Users";
var $helpers = array('Html', 'Form');
function index() {
}
function login()
{
}
function logout()
{
$this->redirect($this->Auth->logout());
}
}
?>
user model
____________________
<?php
class User extends AppModel {
var $name = 'User';
}
?>
login form (login.ctp)
________________________
<div class="login form">
<?php
if ($session->check('Message.auth')) $session->flash('auth');
echo $form->create('Users', array('action' => 'login'));?>
<legend><?php __('Ingresar');?></legend>
<?php
echo $form->input('username');
echo $form->input('password');
echo $form->end('Entrar');
?>
</div>
my app directory is
app/
config/
controllers/
productos_controller
users_controller
.........
models/
producto
user
views/
productos/ --------> in this directory i have index page, this is
the page that i want to REDIRECT
users/ -----------> in this directory i have the login page
...........
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en