user login




	class PeopleController extends CController {

		

		....

		

		public function actionLogin() {

			

			$model = new People;

			if(isset($_POST['People'])) {

				$model->attributes = $_POST['People'];

				$model->scenario = 'login';		

				if($model->validate()) {					

					$this->redirect(Yii::app()->homeUrl);

				}

			}						

						

			$this->render('login',array('model'=>$model));			

		}

		

		....

				

	}

	




	class People extends CActiveRecord {

		

		public $login;

		public $password;




		public static function model($className=__CLASS__) {

			return parent::model($className);			

		}

		

		public function tableName() {

			return '{{users}}';

		}

		

		public function rules() {

			return array(

						array('login,password','required'),

						array('login,password','length','max'=>128,'min'=>3),

						array('password', 'authenticate', 'on' => 'login'),

					);

		}

		

		

		public function authenticate($attribute,$params) {					

			


			if(!$this->hasErrors())

			{	


				$identity= new UserIdentity($this->login, $this->password);

				$identity->authenticate();

					


					switch($identity->errorCode)

					{


						case UserIdentity::ERROR_NONE: {


							Yii::app()->user->login($identity, 0);

							break;

						}

						case UserIdentity::ERROR_USERNAME_INVALID: {


							$this->addError('login',Yii::t('main','Пользователь не найден'));

							break;

						}

						case UserIdentity::ERROR_PASSWORD_INVALID: {


							$this->addError('password',Yii::t('main','Вы указали неверный пароль!'));

							break;

						}

					}

				}

			}		

	}

	




		class UserIdentity extends CUserIdentity

		{

		    private $_id;

		    

		    

		    public function authenticate()

		    {


		        $record=People::model()->findByAttributes(array('login'=>$this->username));        

		        if($record===null)


		            $this->errorCode=self::ERROR_USERNAME_INVALID;            

		        else if($record->password!==md5(md5($this->password)))


		            $this->errorCode=self::ERROR_PASSWORD_INVALID;

		        else

		        {

		            

 

		            $this->_id=$record->id;  

		            $this->errorCode=self::ERROR_NONE;

		        }

		        return !$this->errorCode;

		    }

		 

		    public function getId()

		    {

		        return $this->_id;

		    }

		}

	

1. User does not have a method named "notsafe".


2. And Stack Trace $user=User::model()->notsafe()->findByAttributes(array('username'=>$this->username)); Why User model ? I have people model.

I can not see


$user=User::model()->notsafe()->findByAttributes(array('username'=>$this->username));

code from u codes. It maybe that you did not show us where the code which gives the error.

Check it again.