示例#1
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (\nepster\users\models\User::beforeSave($insert)) {
         if (!empty($this->password)) {
             $this->setPassword($this->password);
         } else {
             $this->password = $this->getOldAttribute('password');
         }
         return true;
     }
     return true;
 }
示例#2
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             // Хешируем пароль
             $this->setPassword($this->password);
             // IP пользователя
             if (!Yii::$app instanceof \yii\console\Application) {
                 $this->ip_register = Yii::$app->request->userIP;
             }
         }
         return true;
     }
     return false;
 }