Hi people,
I’m was developing a application, with a admin module.
In this application, i choose to separate the login from admin module and application.
To do this, i followed this article in wiki: Module Based Login
The login of admin module and application was separate with success, but then i had another problem.
When i’m logging in the application, the returnUrl go to the returnUrl of the module.
By example:
The returnUrl of application is: /site/index
The returnUrl of module is: /admin_emc/default/index
When i’m logging in the module, the returnUrl works normally, but when i efetuate login in the application, i’m redirected to the returnUrl of admin module.
Here go the parts of my code.
Function init of the admin module
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
Yii::app()->user->setStateKeyPrefix('_admin');
$this->setImport(array(
'admin_emc.models.*',
'admin_emc.components.*',
));
$this->setComponents(array(
'errorHandler' => array(
'errorAction' => 'admin_emc/default/error'),
'user' => array(
'class' => 'CWebUser',
'allowAutoLogin' => FALSE,
'loginUrl' => array('/admin_emc/default/login'),
'returnUrl' => array('/admin_emc/default/index'),
)
));
}
In the config file:
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>false,
'loginUrl'=>array('/site/login'),
'returnUrl'=>array('/site/index'),
),
// uncomment the following to enable URLs in path-format
....
In action login of both i used the redirect function to returnUrl:
Admin module: $this->redirect(Yii::app()->getModule(‘admin_emc’)->user->returnUrl);
Application: $this->redirect(Yii::app()->user->returnUrl);
Well, i tried everything, and don’t find nothing like this in the forum.
Hope you can help me.
Abraços