Yii Framework Forum: problem with srbac for an action with parameter - Yii Framework Forum

Jump to content

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

problem with srbac for an action with parameter Rate Topic: -----

#1 User is offline   yuda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 23-December 10

Posted 05 May 2011 - 12:00 AM

I have set an action that has a parameter(e.g actionIndex($p)) to alwaysallowed in srbac system. And it's saved in allowed.php in srbac system. When I try to access the page, I've got this message :

Error:403 'You are not authorized for this action'

Error while trying to access /page/index.

When I try to remove the parameter inside the allowed.php file.It works, I can access those action. What happen actually? is that a bug? or something that I miss???

thanks in advance...

P.S: I've already delete actionRules inside my controller, and I still found those message.
0

#2 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 05 May 2011 - 12:48 AM

can you share your code of controller file so and also a url formate which you use to pass an argument.
then me by i can show you the exact problem..its not an bug..its just a syntex mistake you are doing here...
so just share your code here.so i can show you the error..
CodeSutra
0

#3 User is offline   yuda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 23-December 10

Posted 05 May 2011 - 01:10 AM

View Postjayant, on 05 May 2011 - 12:48 AM, said:

can you share your code of controller file so and also a url formate which you use to pass an argument.
then me by i can show you the exact problem..its not an bug..its just a syntex mistake you are doing here...
so just share your code here.so i can show you the error..


this the url : http://localhost/page/index/p/home
the url manager in main.php
'urlManager'=>array(
	'urlFormat'=>'path',
	'showScriptName'=>false,
	'rules'=>array(
		'<controller:\w+>/<id:\d+>'=>'<controller>/view',
		'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
		'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
		'page/<p:\d+>'=>'page/list',
	),
),


This the action
//controller's properties
public $layout='//layouts/column2';

public function actionIndex($p){
  //the other code in this action only to take care about the models
  $this->render('index',array('model'=>$model,
 			    'modelComment'=>$modelComment,
			    'modelCommentListing'=>$modelCommentListing,
			    'breadCrumbs'=>$this->generateBreadcrumb($model->page_id),
			    'isListing'=>$isListing,
			    'countedComment'=>($countedComment > 0) ? $countedComment: '0'));
}


is that enough?
0

#4 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 05 May 2011 - 01:18 AM

View Postyuda, on 05 May 2011 - 01:10 AM, said:

this the url : http://localhost/page/index/p/home
the url manager in main.php
'urlManager'=>array(
	'urlFormat'=>'path',
	'showScriptName'=>false,
	'rules'=>array(
		'<controller:\w+>/<id:\d+>'=>'<controller>/view',
		'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
		'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
		'page/<p:\d+>'=>'page/list',
	),
),


This the action
//controller's properties
public $layout='//layouts/column2';

public function actionIndex($p){
  //the other code in this action only to take care about the models
  $this->render('index',array('model'=>$model,
 			    'modelComment'=>$modelComment,
			    'modelCommentListing'=>$modelCommentListing,
			    'breadCrumbs'=>$this->generateBreadcrumb($model->page_id),
			    'isListing'=>$isListing,
			    'countedComment'=>($countedComment > 0) ? $countedComment: '0'));
}


is that enough?



yeah that is fine but could you show me that how could you define you url link in a view file..so i would be more clear to me...
CodeSutra
0

#5 User is offline   yuda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 23-December 10

Posted 05 May 2011 - 01:52 AM

View Postjayant, on 05 May 2011 - 01:18 AM, said:

yeah that is fine but could you show me that how could you define you url link in a view file..so i would be more clear to me...



Well, actually those error appear right after I access http://localhost. From there, it will try to reach /site/index, then from actionIndex in site controller it will be redirected to homeUrl(/page/index/p/home).
In my main.php I've declared the homeUrl to /page/index/p/home.

The view file of actionIndex in PageController it self just shows based on the given parameters.

And this is how I construct the links to that page:
 if($items[0]['items'] != "0"){
			
      $items = array_merge(array('items'=>array('label'=>'Home', 'url'=>array('/page/index/p/home'))),
			   $items,								 
			   array(array('label'=>'Contact', 'url'=>array('/site/contact')))); 							
}
		
  $this->widget('zii.widgets.CMenu',array(        
		'items'=>$items,    
  ));
		
?>

0

#6 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 05 May 2011 - 06:00 AM

View Postyuda, on 05 May 2011 - 01:52 AM, said:

Well, actually those error appear right after I access http://localhost. From there, it will try to reach /site/index, then from actionIndex in site controller it will be redirected to homeUrl(/page/index/p/home).
In my main.php I've declared the homeUrl to /page/index/p/home.

The view file of actionIndex in PageController it self just shows based on the given parameters.

And this is how I construct the links to that page:
 if($items[0]['items'] != "0"){
			
      $items = array_merge(array('items'=>array('label'=>'Home', 'url'=>array('/page/index/p/home'))),
			   $items,								 
			   array(array('label'=>'Contact', 'url'=>array('/site/contact')))); 							
}
		
  $this->widget('zii.widgets.CMenu',array(        
		'items'=>$items,    
  ));
		
?>



this is a part where you are doing some mistake.
1.remove the homw url from main config file.
2.defile array url of item properly.like 'url'=>array('/page/index','paramid'=>param)
3.and also try to after commenting a url rules for a once.

try this things and let me know..!!
CodeSutra
0

#7 User is offline   yuda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 23-December 10

Posted 05 May 2011 - 11:22 AM

View Postjayant, on 05 May 2011 - 06:00 AM, said:

this is a part where you are doing some mistake.
1.remove the homw url from main config file.
2.defile array url of item properly.like 'url'=>array('/page/index','paramid'=>param)
3.and also try to after commenting a url rules for a once.

try this things and let me know..!!


Well, found it!!!!
this is what I've done

$keys=array_keys($this->actionParams);
foreach($keys as $key){
	$query=$query.','.'$'.$key;
}
	
$query=substr_replace($query, '',0,1);
$access=$access.$query;


I've added those code to SBaseController.php inside beforeAction method to handle an action with parameter.
0

#8 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 06 May 2011 - 01:34 AM

Which version of srbac do you use?
I could not reproduce this with the latest srbac 1.2v
The "$param" part is not saved in the actions name and in the allowed.php file
0

#9 User is offline   yuda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 23-December 10

Posted 06 May 2011 - 10:34 AM

View PostSpyros, on 06 May 2011 - 01:34 AM, said:

Which version of srbac do you use?
I could not reproduce this with the latest srbac 1.2v
The "$param" part is not saved in the actions name and in the allowed.php file


I'm using 1.1v actually....

I've checked the latest version(1.2v) and my problem fixed with these version... :)
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