Hi all,
I have really strange problem with AuthComponent. Let me explain - the
global AppController:
class AppController extends Controller {
var $components = array('Auth');
function beforeFilter() {
$admin = Configure::read('Routing.admin');
$this->Auth->userModel = 'User';
$this->Auth->fields = array('username' => 'login', 'password' =>
'password');
$this->Auth->loginAction = array('controller' => 'users',
'action'
=> 'login', $admin => false);
$this->Auth->loginRedirect = array('controller' => 'customers',
'action' => 'admin_index');
$this->Auth->logoutRedirect = '/';
$this->Auth->loginError = "Sorry, wrong login or password.";
$this->Auth->authorize = 'controller';
}
function isAuthorized() {
return true;
}
}
Nothing special, just simply setup.
Have DB table 'users' like this:
id (PK)
login varchar(32)
password varchar(64)
And UsersController:
class UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Html', 'Form');
function login() {
}
function logout() {
$this->Session->setFlash("You've successfully logged out.");
$this->redirect($this->Auth->logout());
}
}
?>
And users/login view:
<div class="users form">
<?php echo $form->create('User', array('controller' => 'users',
'action' => 'login'));?>
<fieldset>
<?php
echo $form->input('login');
echo $form->input('password');
?>
</fieldset>
<?php echo $form->end('Login');?>
</div>
AuthComponent perfectly blocked all the actions in app, but it doesn't
seem to log in me :( That's strange, because when I log in, in debug I
get:
1 SELECT `User`.`id`, `User`.`login`, `User`.`password`,
`User`.`group_id`, `User`.`active`, `User`.`created`,
`User`.`modified` FROM `users` AS `User` WHERE `login` = 'root' AND
`password` = 'fbd2effae101c8822a8de42e3e94f9c70da4d214' LIMIT 1
Affected 1
Num. rows 1
Took (ms) 1
So it finds the user in DB for sure. But it won't let me in to any
action and still redirect's to the /users/login page. Cookies are
enabled in the browser. Please help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---