Fill object User

@param array $userData Answer of social network
@param mixed $user Pointer to user object for filling
421324
protected function setUser(array $userData, & $user = null)
    {
        // Generic birthdate parsing
        $user->birthday = date('Y-m-d H:i:s', strtotime($user->birthday));

        // If no external user is passed set as current user
        if (isset($user)) {
            $this->user = & $user;
        }
    }
492378
protected function persistUser(\stdClass $userTmp)
    {
        $user = $this->em
            ->getRepository('AsyncTweetsBundle:User')
            ->findOneById($userTmp->id);

        if (!$user) {
            // Only set the id when adding the User
            $user = new User($userTmp->id);
        }

        // Update other fields
        $user->setValues($userTmp);

        $this->em->persist($user);

        return $user;
    }
712903
protected function createUser(array $data, UserProviderInterface $userManager)
    {
        $userIdentityfield = $this->container->getParameter('rch_jwt_user.user_identity_field');

        $user = $userManager->createUser()
            ->setUsername($data[$userIdentityfield])
            ->setEmail($data[$userIdentityfield])
            ->setEnabled(true)
            ->setPlainPassword($data['password']);

        if (isset($data['facebook_id'])) {
            $user->setFacebookId($data['facebook_id']);
        }

        try {
            $userManager->updateUser($user);
        } catch (\Exception $e) {
            $message = $e->getMessage() ?: 'An error occured while creating the user.';

            throw new UserException(422, $message, $e);
        }

        return $user;
    }
533134
public function addUserData(array $data = [], $reset = false, $override = false) {
        if ($data && is_array($data)) {
            if ($override) {
                $data = array_diff_key($data, $_REQUEST);
            }
            if ($reset) {
                $this->userData = $data;
            } else {
                $this->userData = array_merge($this->userData, $data);
            }
        }
    }
97425
public function setUserAgent($userAgent)
    {
        if ($this->userAgent != $userAgent) {
            $this->reset();
        }
        $this->userAgent = $userAgent;
    }
542033
public function register(array $userData)
    {
        $alreadyCreatedUser = $this->findByEmail($userData['email']);

        if ($alreadyCreatedUser) {
            throw new OutOfBoundsException(
                'A user was already created with this email address.',
                self::EMAIL_NOT_UNIQUE
            );
        }

        $userEntity = new UserEntity;
        $userEntity->setEmail($userData['email'])
            ->setPassword($this->hashPassword($userData['password']))
            ->setCreated(time())
            ->setEnabled(true)
            ->setVerified(false);

        $user = $this->userMapper->persist($userEntity);

        $userToken = $this->createUserToken([
            'token_type_id' => TokenEntity::TYPE_VERIFY_REGISTRATION,
            'user_id'       => $user->getId(),
        ]);

        // Create the verify registration email
        $this->verifyRegistrationView->setToken($userToken);

        $email = $this->emailService->createFromArray([
            'recipient_email' => $user->getEmail(),
            'subject'         => 'Verify Your Account',
            'message'         => (string) $this->verifyRegistrationView,
        ]);

        $this->emailService->enqueueSendEmailJob($email);

        return $user;
    }
939684
public function execute($tokenData = null, $userId = null)
    {
        $batch   = $this->getBatch();
        $tracker = $this->loader->getTracker();

        $batch->addToCounter('checkedTokens');
        $token = $tracker->getToken($tokenData);

        $wasAnswered = $token->isCompleted();

        if ($result = $token->checkTokenCompletion($userId)) {
            if ($result & \Gems_Tracker_Token::COMPLETION_DATACHANGE) {
                $i = $batch->addToCounter('resultDataChanges');
                $batch->setMessage('resultDataChanges', sprintf(
                        $this->_('Results and timing changed for %d tokens.'),
                        $i
                        ));

                if ($wasAnswered) {
                    $action  = 'token.data-changed';
                    $message = sprintf($this->_("Token '%s' data has changed."), $token->getTokenId());
                } else {
                    $action  = 'token.answered';
                    $message = sprintf($this->_("Token '%s' was answered."), $token->getTokenId());
                }
                if (! $this->request instanceof \Zend_Controller_Request_Abstract) {
                    $this->request = \Zend_Controller_Front::getInstance()->getRequest();
                }
                $this->accesslog->logEntry(
                        $this->request,
                        $action,
                        true,
                        $message,
                        $token->getArrayCopy(),
                        $token->getRespondentId()
                        );

            }
            if ($result & \Gems_Tracker_Token::COMPLETION_EVENTCHANGE) {
                $i = $batch->addToCounter('surveyCompletionChanges');
                $batch->setMessage('surveyCompletionChanges', sprintf(
                        $this->_('Answers changed by survey completion event for %d tokens.'),
                        $i
                        ));
            }
        }

        if ($token->isCompleted()) {
            $batch->setTask('Tracker_ProcessTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId);
        }

        $batch->setMessage('checkedTokens', sprintf(
                $this->_('Checked %d tokens.'),
                $batch->getCounter('checkedTokens')
                ));

        // Free memory
        $tracker->removeToken($token);
    }
6723
public function requestToken(array $userData) {
        if (empty($userData['email'])) {
            $this->_addError(
                sprintf(
                    __('%s is a required field'),
                    __('Email')
                )
            );
            return false;
        }

        $validator = new Zend_Validate_EmailAddress();
        if (!$validator->isValid($userData['email'])) {
            $this->_addError(
                sprintf(
                    __('%s is not a valid email address'),
                    __('Email')
                )
            );
            return false;
        }

        $userId = $this->_createOrFetchUserRecord($userData);
        $token  = $this->createOrUpdateAuthRecord($userId);

        $this->_sendTokenEmail($userData['email'], $userId, $token);
        $this->setRedirect($this->_getRedirectUrl());
    }
265164
public function validateUser(CommandData $commandData) {
    $userid = $commandData->input()->getOption('userid');
    if ($userid) {
      $account = User::load($userid);
      if (!$account) {
        throw new \Exception("User ID does not match an existing user.");
      }
    }
  }
571957
public function setUserAgent($userAgent)
    {
        $this->userAgent = $userAgent;
        $uaParser = new \vipnytt\UserAgentParser($this->userAgent);
        $this->userAgentMatch = $uaParser->getMostSpecific(array_keys($this->rules));
        if (!$this->userAgentMatch) {
            $this->userAgentMatch = '*';
        }
    }
782412
public function login( UserData $user ) {
		// clear session
		foreach ( $_SESSION as $key => $value ) {
			unset( $_SESSION[$key] );
		}

		// generate new session id
		session_regenerate_id( true );

		// store user info in session
		$this->setUser( $user );
	}
145281
public function update(User $user, array $data)
    {
        $user->fill([
            'name'                  => $data['name'],
            'email'                 => $data['email'],
            'birthday_at'           => $data['birthday_at'],
            'gender'                => $data['gender'],
            'locale'                => $data['locale'],
            'city'                  => $data['city'],
            'about'                 => $data['about'],
            'profession'            => $data['profession'],
            'hobbies'               => $data['hobbies'],
            'homepage'              => $data['homepage'],
            'skype'                 => $data['skype'],
            'facebook'              => $data['facebook'],
            'twitter'               => $data['twitter'],
            'main_character'        => $data['main_character'],
            'main_guild'            => $data['main_guild'],
            'favorite_race'         => $data['favorite_race'],
            'favorite_class'        => $data['favorite_class'],
            'favorite_spec'         => $data['favorite_spec'],
            'favorite_instance'     => $data['favorite_instance'],
            'favorite_battleground' => $data['favorite_battleground'],
        ]);

        // only fill password if specified
        if (array_key_exists('password', $data)
            && !empty($data['password'])) {
            $user->fill([
                'password' => bcrypt($data['password']),
            ]);
        }

        return $user->save();
    }
659988
public function setUserAgent($userAgent = null)
    {
        if (!empty($userAgent)) {
            $this->userAgent = $userAgent;
        } else {
            $this->userAgent = $this->getHttpHeader('User-Agent');

            if (empty($this->userAgent)) {
                $this->userAgent = $this->getHttpHeader('X-Device-User-Agent');
            }

            //Header can occur on devices using Opera Mini (can expose the real device type).
            //Let's concatenate it (we need this extra info in the regexes).
            if ($operaMiniUa = $this->getHttpHeader('X-OperaMini-Phone-UA')) {
                $this->userAgent .= ' ' . $operaMiniUa;
            }
        }
    }
526726
public static function alreadyConnected(Users $userData, $socialNetwork)
    {
        $source = Sources::findFirst(['title = :title:', 'bind' => ['title' => $socialNetwork]]);

        $bind = [
            'source_id' => $source->source_id,
            'users_id' => $userData->users_id,
        ];

        if ($userSocialLinked = self::findFirst(['source_id = :source_id: and users_id = :users_id:', 'bind' => $bind])) {
            return true;
        }

        return false;
    }
1012395
public function setUserAgent($userAgent)
    {
        if (isset(self::$predefinedUserAgents[$userAgent])) {
            $this->addOption(CURLOPT_USERAGENT, self::$predefinedUserAgents[$userAgent]);
        } else {
            $this->addOption(CURLOPT_USERAGENT, $userAgent);
        }
    }
1276346
public function createNew(array $authData, array $userData) {
        // first save the new user
        $userModel  = new Model_User();
        $userId     = $userModel->insert($userData);
        $userData   = $userModel->find($userId)->current();
        $authData['user_id'] = $userId;
        $this->insert($authData);

        $this->getObserver('Authenticatable')->updateLoginStats($userId);
        return $userData;
    }
666609
public static function create(array $callbackData): self
    {
        $requestedUserInfo = RequestedUserInfo::create($callbackData['requested_user_info']);

        return new self($callbackData['payload'], $requestedUserInfo, $callbackData['amount']);
    }