Authorization With Mulitple Apps

Great framework!!!

I have a project that is broadly organised as per Yii Directory Structure. So the project contains frontend, backend, common and console top level directories. I am also using AuthManager to handle access with yii-auth living in the common directory. The problem I have is that when trying to authorise the different parts of the app, frontend and backend I’m not too sure how to differentiate between them with the authManager operations.

For example both frontend and backend have a defaultController with associated actions. How can I set up an authManager operation for backend.defaultController.index and a separate one for frontend.defaultController .index so that different roles will have different access? I’ve been looking into namespaces but can’t seem to get it to work.

My other options would be to rename the controllers and have an explicit backendDefaultController but it doesn’t seem very tidy.

Any thoughts greatly appreciated…

i think you can externds to both controller…

  1. first you can create the AdminCoreController on comoponents folder and set the defult layout is admin. so it’s backend parts.



<?php

/**

 * Controller is the customized base controller class.

 * All controller classes for this application should extend from this base class.

 */


class AdminCoreController extends GxController

{

	public $layout 		= 'admin';

	public $accessRule  = '';

	public $userType 	= 'admin';

	public $defaultAction = 'admin';

 

}

  1. Second you can create the Front module create the FrontCoreController on componets folder and set the default layout is main on fornt end view folder.

<?php

/**

 * Controller is the customized base controller class.

 * All controller classes for this application should extend from this base class.

 */

class FrontCoreController extends GxController

{

	public $layout='main';


	public function init()

	{

		parent::init();

	}

	

}