/** * Checks if we can recover users password. * This may not possible on e.g. LDAP accounts. */ public function canRecoverPassword($attribute, $params) { if ($this->email != "") { $user = User::findOne(array('email' => $this->email)); $passwordAuth = new \humhub\modules\user\authclient\Password(); if ($user != null && $user->auth_mode !== $passwordAuth->getId()) { $this->addError($attribute, Yii::t('UserModule.forms_AccountRecoverPasswordForm', Yii::t('UserModule.forms_AccountRecoverPasswordForm', "Password recovery is not possible on your account type!"))); } } }
/** * Before Save Addons * * @return type */ public function beforeSave($insert) { if ($insert) { if ($this->auth_mode == '') { $passwordAuth = new \humhub\modules\user\authclient\Password(); $this->auth_mode = $passwordAuth->getId(); } if (Yii::$app->getModule('user')->settings->get('auth.allowGuestAccess')) { // Set users profile default visibility to all if (Yii::$app->getModule('user')->settings->get('auth.defaultUserProfileVisibility') == User::VISIBILITY_ALL) { $this->visibility = User::VISIBILITY_ALL; } } $this->last_activity_email = new \yii\db\Expression('NOW()'); if ($this->status == "") { $this->status = self::STATUS_ENABLED; } } if ($this->time_zone == "") { $this->time_zone = Yii::$app->settings->get('timeZone'); } return parent::beforeSave($insert); }