Friday, January 20, 2012

'roles' not being detected correctly in app controller

I have a user on the database with a 'roles' field set to 'admin' and
a variable $admin that is set in the app controller:

function beforeFilter() {
$this->Auth->allow('index', 'view', 'confirm', 'captcha',
'reload_captcha', 'display');
$this->set('logged_in', $this->_loggedIn());
$this->set('admin', $this->_isAdmin());
}
function _loggedIn() {
$logged_in = false;
if ($this->Auth->user())
$logged_in = true;
return $logged_in;
}
function _isAdmin() {
if (($this->Auth->user()) && ($this->Auth->user('roles') == 'admin'))
return true;
return false;
}

The problem is that the variable $admin is coming back as false in the
default.ctp file.
I am using Cake 2. Any ideas as to what is going on? This worked
fine in Cake 1.3.

Thanks.

--
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: