Yii Bypass Behaviour Request


(Desaikalpesh34) #1

Hello Every One

I have created Behaviour for forcing Login Request

My Behaviour code


<?php

class ApplicationBehavior extends CBehavior

{      

        private $_owner;

        public function events() 

        {

            return  array('onBeginRequest'=>'denyEverything',);

        }

        

        public function denyEverything()

       {

                $owner=$this->getOwner();

                if($owner->user->getIsGuest())

                   $owner->catchAllRequest=array("user/login");

       }

}

?>

Now I want to call Api That is controller Action like

example.com/site/api but its require login for me

how can i overcome this situation??????

i want use this only for Api call(Request from Mobile App).


(Desaikalpesh34) #2

hello

My controller Action Like


public function actionApi()

	{

		$arry=array('myname'=>'My Name Here','Phone'=>'Phone No Here');

		echo json_encode($arry);

	}

is there any way to call this action without login


(Rohisuthar) #3

Follow this tutorial - http://www.yiiframework.com/wiki/738/forcing-login-for-all-pages-using-cbehavior/


(Desaikalpesh34) #4

Thank you for Your Reply…

I have read and its working fine but it is used for some specific Url… isn’t it??

How can i solve for every controller action for api request

In One controller there were many action and system has many controller so array and param value is became large in your solution so is there any alternate solution???