public function process() { $this->validate(); if (!$this->hasErrors()) { if (($model = Yii::app()->getUser()->getModel()) !== null) { return $model->saveAttributes(array('password' => UserHelper::encryptPassword($this->newPassword))); } } return false; }
public function authenticate() { $user = User::model()->findByPk($this->username); if ($user === null) { $this->errorCode = self::ERROR_ID_NUMBER_INVALID; } else { if ($user->password !== UserHelper::encryptPassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $user->uid; $this->errorCode = self::ERROR_NONE; } } return !$this->errorCode; }
public function beforeSave() { if (parent::beforeSave()) { $this->email_address = strtolower($this->email_address); if ($this->getIsNewRecord()) { $this->password = UserHelper::encryptPassword($this->password); $this->deleted = 0; $this->datetime_created = new CDbExpression('now()'); } else { $this->last_modified = new CDbExpression('now()'); } return true; } return false; }