Yii Framework Forum: Redirecionar Usuário Atraves Do Accessrules - Yii Framework Forum

Jump to content

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

Redirecionar Usuário Atraves Do Accessrules Rate Topic: -----

#1 User is offline   Edson Rodrigues 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 378
  • Joined: 10-August 10

Posted 19 November 2013 - 08:26 PM

Como posso redirecionar o usuário para o frontend.

Existe um login no frontend se o usuario for administrador ele será redirecionado ao backend caso contrario para frontend.

Faço este controle no rules, como faço para redirecionar direto no controle utilizando o rules.

Se não for administrador e o usuário tentar entrar via url em algum lugar do backend ele será redirecionado para a home do site.

Meu Rules


public function accessRules()
	{
		return array(
                   
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','view','create','update', 'delete'),
				'users'=>array('@'),
                                'expression'=>'Yii::app()->user->isAdmin',
                                
			),
                         array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('error'),
                                'users'=>array('*'),
                         ),

                        array('deny',  // deny all users
				'users'=>array('*'),
                               
			),
			
			
		);
	}



Agradeço
0

#2 User is offline   lagogz 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 455
  • Joined: 30-November 12
  • Location:Galiza

Posted 03 January 2014 - 05:10 AM

Proba esto nas AccessRules:

array('deny',
'actions'=>array('index','register','login','password'),
'users'=>array('@'),
'deniedCallback' => function() { Yii::app()->controller->redirect(array ('/home/index')); }
),


Un saúdo.
-----------------------------------------------------------------------------------------------
------------------------------- VISITEN FOCUCHASART --------------------------------
-----------------------------------------------------------------------------------------------
0

#3 User is offline   Adrian Lucas 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 229
  • Joined: 13-October 11
  • Location:João Pessoa - Paraíba

Posted 28 February 2014 - 11:22 AM

View Postlagogz, on 03 January 2014 - 05:10 AM, said:

Proba esto nas AccessRules:

array('deny',
'actions'=>array('index','register','login','password'),
'users'=>array('@'),
'deniedCallback' => function() { Yii::app()->controller->redirect(array ('/home/index')); }
),


Un saúdo.

Perfeito!!!!!!!!!!!!!!!!!!Posted ImagePosted Image
Adrian Lucas
A fé em Deus nos faz crer no incrível,
ver o invisível e realizar o impossível.

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