0

Hi iam newbie to yii framework. And iam getting this error after submitting the login details.

error

C:\wamp\www\yii\framework\web\auth\CWebUser.php(154)

152| $this->setState($name,$value);
153| else    
154| parent::__set($name,$value);
155| }

and in STACKTRACE

C:\wamp\www\yiiapp1\protected\models\LoginForm.php(71): CModule->__get("user")

70| $duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
71|             Yii::app()->user->login($this->_identity,$duration);
72|             return true;

THIS IS MY USER.PHP FILE

class user extends CActiveRecord
{
         public function validatePassword($password)
    {
        return CPasswordHelper::verifyPassword($password,$this->password);
    }

    public function hashPassword($password)
    {
        return CPasswordHelper::hashPassword($password);
    }



        public static function model($className=__CLASS__)
        {
                return parent::model($className);
        }


        public function tableName()
        {
                return 'user';
        }

        public function rules()
        {

                return array(
                        array('', 'safe', 'on'=>'search'),
                );
        }

        public function relations()
        {

                return array(
                );
        }


        public function attributeLabels()
        {
                return array(
                );
        }


        public function search()
        {


                $criteria=new CDbCriteria;

                return new CActiveDataProvider('user', array(
                        'criteria'=>$criteria,
                ));
        }
}

LOGINFORM

class LoginForm extends CFormModel
{
        public $username;
        public $password;
        public $rememberMe;
        private $_identity;


        public function rules()
        {
                return array(
                        // username and password are required
                        array('username, password', 'required'),
                        // rememberMe needs to be a boolean
                        array('rememberMe', 'boolean'),
                        // password needs to be authenticated
                        array('password', 'authenticate'),
                );
        }


        public function attributeLabels()
        {
                return array(
                        'rememberMe'=>'Remember me next time',
                );
        }

        public function authenticate($attribute,$params)
        {
                if(!$this->hasErrors())
                {
                        $this->_identity=new UserIdentity($this->username,$this->password);
                        if(!$this->_identity->authenticate())
                                $this->addError('password','Incorrect username or password.');
                }
        }


public function login($identity,$duration)
        {
                if($this->_identity===null)
                {
                        $this->_identity=new UserIdentity($this->username,$this->password);
                        $this->_identity->authenticate();
                }
                if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
                {

                        $duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
                        Yii::app()->user->login($this->_identity,$duration);// --> HERE THE STACKTRACE SHOWING THE ERROR
                        return true;
                }
                else
                        return false;
        }
}
1
  • 1
    clientScript is a property of CWebApplication (the application itself, which you access through Yii::app()). You seem to be setting this property on Yii::app()->user. Look through your entire callstack and you'll find where it happens, nobody can help you without your code. Commented Jul 24, 2013 at 19:49

1 Answer 1

1

It seem you use Yii::app()->user->clientScript;, just replace it by Yii::app()->clientScript

Sign up to request clarification or add additional context in comments.

1 Comment

hi thanks for the reply. I removed the user from there. Then it is saying CWebApplication and its behaviors do not have a method or closure named "login"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.