/** * Set object properties from forceValues in TypoScript * * @param User $user * @param array $settings * @return User $object */ public static function forceValues(User $user, array $settings) { foreach ((array) $settings as $field => $config) { $config = null; if (stristr($field, '.')) { continue; } // value to set $value = self::getContentObject()->cObjGetSingle($settings[$field], $settings[$field . '.']); if ($field === 'usergroup') { // need objectstorage for usergroup field $user->removeAllUsergroups(); $values = GeneralUtility::trimExplode(',', $value, true); $userGroupRepository = self::getUserGroupRepository(); foreach ($values as $usergroupUid) { /** @var UserGroup $usergroup */ $usergroup = $userGroupRepository->findByUid($usergroupUid); $user->addUsergroup($usergroup); } } else { // set value if (method_exists($user, 'set' . ucfirst($field))) { $user->{'set' . ucfirst($field)}($value); } } } return $user; }
/** * action create * * @param User $user * @validate $user In2code\Femanager\Domain\Validator\ServersideValidator * @validate $user In2code\Femanager\Domain\Validator\PasswordValidator * @validate $user In2code\Femanager\Domain\Validator\CaptchaValidator * @return void */ public function createAction(User $user) { $this->allowedUserForInvitationNewAndCreate(); $user->setDisable(true); $user = FrontendUtility::forceValues($user, $this->config['invitation.']['forceValues.']['beforeAnyConfirmation.']); $user = UserUtility::fallbackUsernameAndPassword($user); if ($this->settings['invitation']['fillEmailWithUsername'] === '1') { $user->setEmail($user->getUsername()); } UserUtility::hashPassword($user, $this->settings['invitation']['misc']['passwordSave']); $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforePersist', [$user, $this]); $this->createAllConfirmed($user); }
/** * @test * @return void */ public function setUsernameForStringSetsUsername() { $this->fixture->setUsername('Conceived at T3CON10'); $this->assertSame('Conceived at T3CON10', $this->fixture->getUsername()); }
/** * Check if user is authenticated * * @param User $user * @param int $uid Given fe_users uid * @return void */ protected function testSpoof($user, $uid) { if ($user->getUid() !== (int) $uid && $uid > 0) { LogUtility::log(Log::STATUS_PROFILEUPDATEREFUSEDSECURITY, $user); $this->addFlashMessage(LocalizationUtility::translateByState(Log::STATUS_PROFILEUPDATEREFUSEDSECURITY), '', FlashMessage::ERROR); $this->forward('edit'); } }
/** * @param User $user * @return bool */ protected function isAdminConfirmationMissing(User $user) { return !empty($this->settings['new']['confirmByAdmin']) && !$user->getTxFemanagerConfirmedbyadmin(); }
/** * Create hash for a user * * @param User $user * @return string */ public static function createHashForUser(User $user) { return self::hashString($user->getUsername()); }
/** * @param User $user * * @return void */ protected function emailForUsername(User $user) { if ($this->settings['edit']['fillEmailWithUsername'] === '1') { $user->setEmail($user->getUsername()); } }
/** * Check if FE Session exists * * @param User $user * @return bool */ public static function checkFrontendSessionToUser(User $user) { $select = 'ses_id'; $from = 'fe_sessions'; $where = 'ses_userid = ' . (int) $user->getUid(); $res = self::getDatabaseConnection()->exec_SELECTquery($select, $from, $where); $row = self::getDatabaseConnection()->sql_fetch_assoc($res); return !empty($row['ses_id']); }
/** * Initialize * * @param User $user * @return void */ protected function initialize(User $user) { $this->properties = $user->_getCleanProperties(); $this->contentObject = $this->configurationManager->getContentObject(); }