Monday, December 26, 2011

Auth component troubles

I'm having troubles with the Auth component using CakePHP 1.3

I expected the following to work:

<?php
class AppController extends Controller {

var $components = array('Auth');

function beforeFilter() {
$this->Auth->fields = array(
'username' => 'email',
'password' => 'password'
);
$this->Auth->loginError = "Wrong!";
}

}
?>

<?php
class UsersController extends AppController {

var $name = 'Users';

function login() {
}

function logout() {
$this->redirect($this->Auth->logout());
}
}

?>

Yet it won't authenticate correctly until I move the beforeFilter() from AppController and put it in the UsersController, along with adding "var $components = array('Auth');" which the Cake Book says: "Not necessary if declared in your app controller" which appears to be incorrect.

I want to declare all the Auth variables in the AppController so that they're site-wide, but it doesn't work when I do. Any suggestions one what I've done wrong?

Thanks!

Clint

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: