Answer the question
In order to leave comments, you need to log in
Yii how to make different authorizations in different modules?
There is a site on Yii. It assumes 2 sources of authorization
- On the site itself, authorization through social networks using the EAuth module ( habrahabr.ru/post/129804/)
- There is a control panel for "suppliers". Made in the form of a module. Normal authorization from base of local users is planned there. I screwed www.yiiframework.com/extension/yii-user In
the porstors I found about setStateKeyPrefix but in fact it does not help.
in the suppliers module
class CpModule extends CWebModule
{
public function init()
{
$this->setComponents(array(
'errorHandler' => array(
'errorAction' => 'site/error'),
'user' => array(
'class' => 'CWebUser',
'allowAutoLogin'=>true,
'stateKeyPrefix' => '_cp',
'loginUrl' => Yii::app()->createUrl('user/login'),
)
));
// 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(
'cp.models.*',
'cp.components.*',
'application.modules.user.models.*',
'application.modules.user.components.*',
));
}
protected function getStateKeyPrefix() {
return '__eauth_' . $this->getServiceName() . '__';
}
protected function hasState($key) {
$session = Yii::app()->session;
$key = $this->getStateKeyPrefix() . $key;
return isset($session[$key]);
}
Answer the question
In order to leave comments, you need to log in
There was a similar situation. Too many problems from simultaneous authorizations within the same application instance. Try splitting applications into parts according to www.yiiframework.com/wiki/63 so that one part of the application will not depend on the other, and you can configure everything without problems
First, try passing false as the second parameter to setComponents. This will force the module to replace the component, not to merge.
If this does not help, as an option, you can register 2 WebUser components under different names. Accordingly, depending on the context, use the desired component.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question