Yii Framework Forum: Cannot Use Rbac - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cannot Use Rbac Rate Topic: -----

#1 User is offline   jeremy07b 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 18-February 14

Posted 29 March 2014 - 08:31 AM

C:\wamp\www\hello\protected>yiic rbac
exception 'CException' with message 'Property "CDbConnection.authManager" is not
defined.' in C:\wamp\www\yii\framework\base\CComponent.php:173
Stack trace:
#0 C:\wamp\www\yii\framework\YiiBase.php(220): CComponent->__set('authManager',
Array)
#1 C:\wamp\www\yii\framework\base\CModule.php(386): YiiBase::createComponent(Arr
ay)
#2 C:\wamp\www\yii\framework\web\auth\CDbAuthManager.php(589): CModule->getCompo
nent('db')
#3 C:\wamp\www\yii\framework\web\auth\CDbAuthManager.php(59): CDbAuthManager->ge
tDbConnection()
#4 C:\wamp\www\yii\framework\base\CModule.php(387): CDbAuthManager->init()
#5 C:\wamp\www\yii\framework\base\CModule.php(103): CModule->getComponent('authM
anager')
#6 C:\wamp\www\hello\protected\commands\RbacCommand.php(137): CModule->__get('au
thManager')
#7 C:\wamp\www\hello\protected\commands\RbacCommand.php(23): RbacCommand->ensure
AuthManagerDefined()
#8 [internal function]: RbacCommand->actionIndex()
#9 C:\wamp\www\yii\framework\console\CConsoleCommand.php(172): ReflectionMethod-
>invokeArgs(Object(RbacCommand), Array)
#10 C:\wamp\www\yii\framework\console\CConsoleCommandRunner.php(71): CConsoleCom
mand->run(Array)
#11 C:\wamp\www\yii\framework\console\CConsoleApplication.php(92): CConsoleComma
ndRunner->run(Array)
#12 C:\wamp\www\yii\framework\base\CApplication.php(180): CConsoleApplication->p
rocessRequest()
#13 C:\wamp\www\yii\framework\yiic.php(33): CApplication->run()
#14 C:\wamp\www\hello\protected\yiic.php(7): require_once('C:\wamp\www\yii...')
#15 {main}
0

#2 User is offline   jeremy07b 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 18-February 14

Posted 29 March 2014 - 08:33 AM

please help i cannot use rbac because of this
0

#3 User is offline   Ahamed Rifaideen 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 383
  • Joined: 14-February 13
  • Location:chennai, tamilnadu

Posted 29 March 2014 - 10:01 AM

View Postjeremy07b, on 29 March 2014 - 08:33 AM, said:

please help i cannot use rbac because of this

there might be problem in your authMamager configuration
post your code here we will help you
My Blog - Yii Learner
0

#4 User is offline   jeremy07b 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 18-February 14

Posted 29 March 2014 - 10:18 AM

View PostAhamed Rifaideen, on 29 March 2014 - 10:01 AM, said:

there might be problem in your authMamager configuration
post your code here we will help you

where is it found? in protected?
0

#5 User is offline   Ahamed Rifaideen 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 383
  • Joined: 14-February 13
  • Location:chennai, tamilnadu

Posted 29 March 2014 - 10:25 AM

post protected/config/main.php's modules array
My Blog - Yii Learner
0

#6 User is offline   jeremy07b 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 18-February 14

Posted 29 March 2014 - 10:28 AM

View PostAhamed Rifaideen, on 29 March 2014 - 10:25 AM, said:

post protected/config/main.php's modules array

<?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',
	'theme'=>'blackboot',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		/**/
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>false,
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		
	),

	// application components
		'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			),
			'authManager'=>array(
			'class'=>'CDbAuthManager',
			'connectionID'=>'db',
			'itemTable' =>'tbl_auth_item',
			'itemChildTable' =>'tbl_auth_item_child',
			'assignmentTable' =>'tbl_auth_assignment',
			
		),
		// 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/test1.db',
		),
		// uncomment the following to use a MySQL database
		
		'db'=>array(
			'connectionString' => 'mysql:host=127.0.0.1;dbname=test1',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',
			'charset' => 'utf8',
		),
		
		'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',
	),
);

0

#7 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,698
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 29 March 2014 - 10:42 AM

Actually the other one needed, console.php, since it's console command you're running.

PS. How come you have two 'db' keys in main.php?
God is real unless declared as integer
0

#8 User is offline   Ahamed Rifaideen 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 383
  • Joined: 14-February 13
  • Location:chennai, tamilnadu

Posted 29 March 2014 - 10:51 AM

you have db components twice one with sqlite and another with mysql so make them unique. and explain me in what situation did u received this error
My Blog - Yii Learner
0

#9 User is offline   jeremy07b 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 18-February 14

Posted 29 March 2014 - 11:25 AM

Now im getting a another error on cmd


C:\wamp\www\hello\protected>yiic rbac
This command will create three roles: Owner, Member, and Reader
 and the following permissions:
create, read, update and delete user
create, read, update and delete project
create, read, update and delete issue
Would you like to continue? (yes|no) [no]:yes
exception 'CDbException' with message 'CDbCommand failed to execute the SQL sta
ement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General
error: 1 no such table: tbl_auth_assignment. The SQL statement executed was: DE
ETE FROM 'tbl_auth_assignment'' in C:\wamp\www\yii\framework\db\CDbCommand.php:
58
Stack trace:
#0 C:\wamp\www\yii\framework\db\CDbCommand.php(1302): CDbCommand->execute(Array

#1 C:\wamp\www\yii\framework\web\auth\CDbAuthManager.php(560): CDbCommand->dele
e('tbl_auth_assign...')
#2 C:\wamp\www\yii\framework\web\auth\CDbAuthManager.php(550): CDbAuthManager->
learAuthAssignments()
#3 C:\wamp\www\hello\protected\commands\RbacCommand.php(39): CDbAuthManager->cl
arAll()
#4 [internal function]: RbacCommand->actionIndex()
#5 C:\wamp\www\yii\framework\console\CConsoleCommand.php(172): ReflectionMethod
>invokeArgs(Object(RbacCommand), Array)
#6 C:\wamp\www\yii\framework\console\CConsoleCommandRunner.php(71): CConsoleCom
and->run(Array)
#7 C:\wamp\www\yii\framework\console\CConsoleApplication.php(92): CConsoleComma
dRunner->run(Array)
#8 C:\wamp\www\yii\framework\base\CApplication.php(180): CConsoleApplication->p
ocessRequest()
#9 C:\wamp\www\yii\framework\yiic.php(33): CApplication->run()
#10 C:\wamp\www\hello\protected\yiic.php(7): require_once('C:\wamp\www\yii...')
#11 {main}


and this is my console.php


<?php

// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My Console Application',

	// preloading 'log' component
	'preload'=>array('log'),

	// application components
	
	'components'=>array('authManager'=>array(
			'class'=>'CDbAuthManager',
			'connectionID'=>'db',
			'itemTable' =>'tbl_auth_item',
			'itemChildTable' =>'tbl_auth_item_child',
			'assignmentTable' =>'tbl_auth_assignment',
),
		'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' => '',
			'charset' => 'utf8',
		),
		*/
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
			),
		),
	),
);

0

#10 User is offline   jeremy07b 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 18-February 14

Posted 29 March 2014 - 11:27 AM

Problem resolve.. thank you :D
0

#11 User is offline   skapeyi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 22-November 13
  • Location:Uganda

Posted 01 April 2014 - 03:36 AM

View Postjeremy07b, on 29 March 2014 - 11:27 AM, said:

Problem resolve.. thank you :D

What was the problem? Wrong table naming i am guessing, right?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users