Hi,
Thanks for the code.
I’m a Yii newbie and downloaded your code and followed your instructions and installed in a fresh testdrive yii application.
The install worked fine. I got to the congratulations page which told me to login using admin/admin as the username and pwd.
The problem:
I’m getting an error message when i try to login using admin/admin.
Here’s the full error message and below my config/main.php
Any help is very much appreciated, many thanks!!
best,
bartes
Error:
CException
Description
Property "CWebUser.isAdmin" is not defined.
Source File
/Applications/MAMP/htdocs/yii/framework/web/auth/CWebUser.php(108)
00096: /**
00097: * PHP magic method.
00098: * This method is overriden so that persistent states can be accessed like properties.
00099: * @param string property name
00100: * @return mixed property value
00101: * @since 1.0.3
00102: */
00103: public function __get($name)
00104: {
00105: if($this->hasState($name))
00106: return $this->getState($name);
00107: else
00108: return parent::__get($name);
00109: }
00110:
00111: /**
00112: * PHP magic method.
00113: * This method is overriden so that persistent states can be set like properties.
00114: * @param string property name
00115: * @param mixed property value
00116: * @since 1.0.3
00117: */
00118: public function __set($name,$value)
00119: {
00120: if($this->hasState($name))
Stack Trace
#0 /Applications/MAMP/htdocs/yii/framework/web/auth/CWebUser.php(108): CComponent->__get(‘isAdmin’)
#1 /Applications/MAMP/htdocs/yii/framework/base/CComponent.php(264): CWebUser->__get(‘isAdmin’)
#2 [internal function]: CComponent->__call(‘isAdmin’, Array)
#3 /Applications/MAMP/htdocs/yii/framework/base/CComponent.php(616) : eval()'d code(1): CWebUser->isAdmin()
#4 /Applications/MAMP/htdocs/yii/framework/base/CComponent.php(616): eval()
#5 /Applications/MAMP/htdocs/yii/framework/web/auth/CAccessControlFilter.php(337): CComponent->evaluateExpression(‘Yii::app()->use…’, Array)
#6 /Applications/MAMP/htdocs/yii/framework/web/auth/CAccessControlFilter.php(240): CAccessRule->isExpressionMatched(Object(CWebUser))
#7 /Applications/MAMP/htdocs/yii/framework/web/auth/CAccessControlFilter.php(111): CAccessRule->isUserAllowed(Object(CWebUser), Object(YumUserController), Object(CInlineAction), ‘::1’, ‘GET’)
#8 /Applications/MAMP/htdocs/yii/framework/web/filters/CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain))
#9 /Applications/MAMP/htdocs/yii/framework/web/CController.php(1049): CFilter->filter(Object(CFilterChain))
#10 /Applications/MAMP/htdocs/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#11 /Applications/MAMP/htdocs/yii/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))
#12 /Applications/MAMP/htdocs/yii/framework/web/CController.php(283): CFilterChain->run()
#13 /Applications/MAMP/htdocs/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#14 /Applications/MAMP/htdocs/yii/framework/web/CWebApplication.php(324): CController->run(‘adminpanel’)
#15 /Applications/MAMP/htdocs/yii/framework/web/CWebApplication.php(121): CWebApplication->runController(‘user/user/admin…’)
#16 /Applications/MAMP/htdocs/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()
#17 /Applications/MAMP/htdocs/testdrive/index.php(13): CApplication->run()
#18 {main}
config/main.php:
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias(‘local’,‘path/to/local-folder’);
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.user.models.*',
),
/*
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
),
),
*/
'modules' => array(
'user' => array(
'modules' => array(
'role',
'profiles',
'messages',
),
'debug' => true,
)
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl' => array('/user/user/login'),
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'tablePrefix' => '',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);