public function beforeSave($insert) { if ($insert) { $this->setAttribute('auth_key', Yii::$app->security->generateRandomString()); $this->setAttribute('role', $this->module->defaultRole); $this->setAttribute('status', $this->module->confirmable ? SELF::STATUS_NOT_ACTIVE : SELF::STATUS_ACTIVE); } if (!empty($this->password)) { $this->setAttribute('password_hash', Yii::$app->security->generatePasswordHash($this->password)); } return parent::beforeSave($insert); }