/** @inheritdoc */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->isAttributeChanged('gravatar_email')) { $this->setAttribute('gravatar_id', md5(strtolower($this->getAttribute('gravatar_email')))); } return true; } return false; }
/** @inheritdoc */ public function beforeSave($insert) { if ($insert) { $this->setAttribute('auth_key', \Yii::$app->security->generateRandomString()); if (\Yii::$app instanceof \yii\web\Application) { $this->setAttribute('registration_ip', \Yii::$app->request->userIP); } } if (!empty($this->password)) { if (!empty($this->getOldAttribute('password_hash'))) { $this->passwordChanged = !Password::validate($this->password, $this->getOldAttribute('password_hash')); } $this->setAttribute('password_hash', Password::hash($this->password)); } return parent::beforeSave($insert); }