@param UserInterface $user
@param               $plainPassword

@return int
765587
public function setUser(UserInterface $user, $plainPassword = '')
    {
        $class = $this->getGameOptions()->getEntityAccountTbUser();
        $accEntityManager = $this->getAccountEntityManager();

        if ((bool)$user->getBackendId()) {
            $jid = $user->getBackendId();

            $repoTbUser = $accEntityManager->getRepository($class);
            /** @var \GameBackend\Entity\SRO\Account\TbUser $tbUser */
            $tbUser = $repoTbUser->findOneBy(['jid' => $jid]);
        } else {
            /** @var \GameBackend\Entity\SRO\Account\TbUser $tbUser */
            $tbUser = new $class();
            $tbUser->setStruserid($user->getUsername());
            $tbUser->setEmail($user->getEmail());
            $tbUser->setRegIp($user->getCreateIp());
        }

        $password = $plainPassword ? $this->hashPassword($plainPassword) : $user->getPassword();

        $tbUser->setPassword($password);
        $accEntityManager->persist($tbUser);
        $accEntityManager->flush();

        return $tbUser->getJid();
    }
1369074
protected function getUserId(UserInterface $user)
    {
        $class = $this->container->getParameter('tree_house.keystone.model.user.class');
        $meta = $this->getDoctrine()->getManagerForClass($class)->getClassMetadata($class);

        $ids = $meta->getIdentifierValues($user);
        if (sizeof($ids) === 1) {
            return current($ids);
        }

        return $ids;
    }
1207915
private function getUserObjectPermission(SecurityCondition $securityCondition, UserInterface $user)
    {
        $permissions = $this->getPermissions($securityCondition->getObjectType(), $securityCondition->getObjectId());

        return $this->getUserObjectPermissionByArray($permissions, $user);
    }
793477
public function createToken(UserInterface $user = null)
    {
        if(!$user) {
            $user = $this->getObject('user');
        }

        $token = $this->getObject('lib:http.token')
            ->setSubject($user->getId())
            ->sign($this->getSecret());

        return $token;
    }
579356
private function resetEmail(UserInterface $user)
    {
        $ttl = $this->container->getParameter('fos_user.resetting.token_ttl');
        if ($user->isPasswordRequestNonExpired($ttl)) {
            return self::RESET_EMAIL_ALREADY_SENT;
        }

        if (null === $user->getConfirmationToken()) {
            /**
             * @var $tokenGenerator \FOS\UserBundle\Util\TokenGeneratorInterface
             */
            $tokenGenerator = $this->container->get('fos_user.util.token_generator');
            $user->setConfirmationToken($tokenGenerator->generateToken());
        }

        $this->container->get('session')->set(
            static::SESSION_EMAIL,
            $this->getObfuscatedEmail($user)
        );
        $this->container->get('fos_user.mailer')->sendResettingEmailMessage($user);
        $user->setPasswordRequestedAt(new \DateTime());
        $this->container->get('fos_user.user_manager')->updateUser($user);

        return self::RESET_EMAIL_OK;
    }
821211
public function sendReset(UserInterface $user)
    {
        $view = Config::get('cpanel::views.email_password_forgot');
        $code = $user->getResetPasswordCode();

        Mail::queue($view, compact('code'), function($message) use ($user)
        {
            $message->to($user->email)->subject('Account Password Reset');
        });
    }
703724
private function askForUsers(InputInterface $input, OutputInterface $output) {
        $question = new Question(
            'On which users should the public key have access to these resources?' . PHP_EOL .
            '(comma-separated, specify "*" for all users) '
        );
        $question->setValidator(function($answer) {
            $users = array_filter(array_map('trim', explode(',', $answer)));

            if (empty($users)) {
                throw new RuntimeException(
                    'You must specify at least one user, alternatively a wildcard character (*)'
                );
            }

            return array_search('*', $users) === false ? $users : '*';
        });

        return $this->getHelper('question')->ask($input, $output, $question);
    }
862419
public function setUser(UserInterface $user)
    {
        Base::instance()->mset([
            static::SESSION_USER => $user->getUsername(),
            static::SESSION_LOGIN => true,
        ]);
        $this->user = $user;
    }
928899
protected function createRememberTokenIfDoesntExist(UserInterface $user)
    {
        $rememberToken = $user->getRememberToken();

        if (empty($rememberToken)) {
            $this->refreshRememberToken($user);
        }
    }
66836
private function encodePassword(User $user)
    {
        $password = $this->encoderFactory
            ->getEncoder($user)
            ->encodePassword($user->getPlainPassword(), $user->getSalt());

        $user->setPassword($password);

        return $password;
    }
490798
public function dispatchOnPasswordRecoverEvent(AbstractUserInterface $user)
    {
        $event = new PasswordRecoverEvent($user);
        $this
            ->eventDispatcher
            ->dispatch(
                ElcodiUserEvents::PASSWORD_RECOVER,
                $event
            );
    }
256396
public function notifyPasswordReset(User $user, $plainPassword)
    {
        $fromEmail = $this->container->getParameter("default_mail_from");
        $fromName = $this->container->getParameter("default_mail_from_name");
        $appName = $this->container->getParameter("default_app_name");
        $subject = "[$appName] Cambio de datos";
        $toEmail = $user->getEmail();
        $toName = $user->getFirstname();
        $body = $this->container->get('templating')->render('FlowcodeUserBundle:Email:notifyPasswordReset.html.twig', array('user' => $user, 'plainPassword' => $plainPassword));

        $this->mailSender->send($toEmail, $toName, $fromEmail, $fromName, $subject, $body, true);
    }
449998
public function getCoins(UserInterface $user)
    {
        $class = $this->getGameOptions()->getEntityAccountClass();
        $accEntityManager = $this->getAccountEntityManager();

        /** @var \GameBackend\Entity\Metin\Account\Repository\Account $repoAccount */
        $repoAccount = $accEntityManager->getRepository($class);
        $metinUser = $repoAccount->getUser($user);

        $result = 0;
        if ($metinUser) {
            $result = $metinUser->getCash();
        }

        return $result;
    }
473158
public function createToken(UserInterface $user, string $operator = null): TokenInterface
    {
        return $this->getOperator($operator ?? $this->config->defaultOperator())->createToken($user);
    }
1055110
public function isPasswordValid($plainPassword, $user = null)
    {
        $user = $user ?: $this->getUser();

        return $this->passwordEncoder->isPasswordValid($user, $plainPassword);
    }
988852
public static function verifyHashedPassword(User $user, $passwordGiven)
    {
        $bcrypt = new Bcrypt(array('cost' => 10));
        return $bcrypt->verify($passwordGiven, $user->getPassword());
    }
531420
public static function isUsed($password, $user = null)
    {
        if (!User::isValid($user)) {
            throw new InvalidParamException('User Invalid.');
        }
        $passwords = static::find()->createdBy($user)->all();
        foreach ($passwords as $p) {
            /* @var $p static */
            if ($p->validatePassword($password)) {
                return $p;
            }
        }
        return false;
    }