How to override Yii Login URL Modul for module?
here is the main configuration for base application:
return array(
.........
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl' => '/site/login',
),
..........
);
And then i have agent module, i want in this this module the login URL is different and login method is also different.
class AgentModule extends CWebModule {
public function init() {
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'agent.models.*',
'agent.components.*',
));
$this->defaultController = 'default';
$this->layoutPath = Yii::getPathOfAlias('agent.views.layout');
$this->components = array(
'user' => array(
'class' => 'AgentUserIdentity',
'loginUrl' => '/agent/default/login',
)
);
}
.......
But i don’t know why this not work.
Please help… (T.T)
In 2nd code block in your question you defined
usercomponent for moduleAgentModule.If i understand right, somewhere in your view or controller you use
Yii::app()->user->loginUrl, right? To get url defined inAgentModuleyou should useYii::app()->user->controller->module->userbut only while inAgentModulecontext.Easiest way to make it different is to define somewhere login urls for module, and for app, and just use this predefined urls.
Try reading about module compoents here: http://www.yiiframework.com/wiki/27/how-to-access-a-component-of-a-module-from-within-the-module-itself/