/** * Функция которая сбрасывает пароль на новый * @param String $username Имя пользователя * @param String $key Ключ для сброса пароля, который был выслан ему по почте * @return */ public function actionResetPassword($username, $key) { $criteria = new SDbCriteria(); $criteria->compare('username', $username); $criteria->compare('is_social_user', Buyer::SOCIAL_BUYER_NO); $criteria->compare('reset_key', $key); $model = AR::model($this->model)->find($criteria); if (!$model) { exception(404); } $model->scenario = 'resetPassword'; $model->password = ''; $this->performAjaxValidation($model); if (isset($_POST[$this->model])) { $model->attributes = $_POST; //save new password and salt if ($model->save()) { //set flash message setFlash('password-changed', 'password-change-success'); } } $this->pageTitle = t('user', 'Смена пароля'); $this->render('forgotpassword', compact('model')); }
/** * Model * @param $classname * @return CModel */ public static function model($classname = __CLASS__) { return parent::model($classname); }