Yii Framework Forum: Module Based Login And User Level Acces System - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Module Based Login And User Level Acces System Rate Topic: -----

#1 User is offline   hemc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 87
  • Joined: 09-July 12
  • Location:New Delhi

Posted 27 November 2012 - 02:44 AM

i have implemented module based login from
http://www.yiiframew...le-based-login/
by update 2 method and it works fine for me .
Now there is need to access this module as different role,
i implement user level access to this module as described here
http://www.yiiframew...-access-system/
i add LevelLookUp class to EWebUser.
when i try to login now a CException
"CWebUser and its behaviors do not have a method or closure named "isAdmin". "
displayed.
it means module is still using CWebUser, but i create my own EWebUser and place it to module/components/EWebUser.php
and code in module config file init method
$this->setImport(array(
            'bgadmin.models.*',
            'bgadmin.components.*',
        ));
        $this->setComponents(
                array(
                    'errorHandler' => array(
                        'errorAction' => 'bgadmin/default/error'),
                    'user' => array(
                        //'class' => 'CWebUser',
                        'class' => 'EWebUser',
                        'loginUrl' => Yii::app()->createUrl('bgadmin/default/index'),
                    )
        ));

Problem-
1.why module is still using CWebuser instead of EWebUser ?


RETRY------------
when i change
 $this->setComponents(
to
 Yii::app()->setComponents(

then it access the EwebUser but not the loginurl as i logged in but now 2 PROBLEMS
1.'expression'=>'Yii::app()->user->isAdmin()' not works but in class EwebUser it return flase.
2.when logout give error "Property "BgadminModule.user" is not defined. "
logout code is
 Yii::app()->user->logout(false);
        $this->redirect(Yii::app()->getModule('bgadmin')->user->loginUrl);

in previous case logout was working fine.
Please help me.
Please don't add a reply to say thanks, There is already a +1 button to do same.
0

#2 User is offline   suriyansuresh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 23-July 10
  • Location:Coimbatore, India

Posted 28 January 2013 - 05:15 AM

Could you post EWebUser class code here if possible?. Check your EWebuser class whether it extends CWebUser

View Posthemc, on 27 November 2012 - 02:44 AM, said:

i have implemented module based login from
http://www.yiiframew...le-based-login/
by update 2 method and it works fine for me .
Now there is need to access this module as different role,
i implement user level access to this module as described here
http://www.yiiframew...-access-system/
i add LevelLookUp class to EWebUser.
when i try to login now a CException
"CWebUser and its behaviors do not have a method or closure named "isAdmin". "
displayed.
it means module is still using CWebUser, but i create my own EWebUser and place it to module/components/EWebUser.php
and code in module config file init method
$this->setImport(array(
            'bgadmin.models.*',
            'bgadmin.components.*',
        ));
        $this->setComponents(
                array(
                    'errorHandler' => array(
                        'errorAction' => 'bgadmin/default/error'),
                    'user' => array(
                        //'class' => 'CWebUser',
                        'class' => 'EWebUser',
                        'loginUrl' => Yii::app()->createUrl('bgadmin/default/index'),
                    )
        ));

Problem-
1.why module is still using CWebuser instead of EWebUser ?


RETRY------------
when i change
 $this->setComponents(
to
 Yii::app()->setComponents(

then it access the EwebUser but not the loginurl as i logged in but now 2 PROBLEMS
1.'expression'=>'Yii::app()->user->isAdmin()' not works but in class EwebUser it return flase.
2.when logout give error "Property "BgadminModule.user" is not defined. "
logout code is
 Yii::app()->user->logout(false);
        $this->redirect(Yii::app()->getModule('bgadmin')->user->loginUrl);

in previous case logout was working fine.
Please help me.

Suriyan

Yii application development | Web design
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users