@param string $user

@return User

@throws InvalidHmacException
@throws InvalidCipherTextException
965086
public function deserializeFromString($user)
    {
        $base64EncodedUserValues = json_decode(base64_decode($user), true);
        if (!is_array($base64EncodedUserValues)) {
            return null;
        }

        if (empty($base64EncodedUserValues)) {
            return null;
        }

        $expectedKeys = [
            self::SERIALIZED_USER_USERNAME_KEY,
            self::SERIALIZED_USER_PASSWORD_KEY,
            self::SERIALIZED_USER_KEY_KEY,
        ];

        foreach ($expectedKeys as $expectedKey) {
            if (!isset($base64EncodedUserValues[$expectedKey])) {
                return null;
            }
        }

        $userValues = [];

        foreach ($base64EncodedUserValues as $key => $value) {
            $base64DecodedValue = base64_decode($value);
            if ($base64DecodedValue == '') {
                return null;
            }

            $userValues[$key] = $base64DecodedValue;
        }

        return $this->deserialize($userValues);
    }
587048
protected function getUserId($user) : ?int
    {
        if ($user === null) {
            return null;
        }

        if (is_int($user)) {
            return $user;
        }

        if ($user instanceof Authenticatable) {
            return $user->getAuthIdentifier();
        }

        return null;
    }
476560
public function create(User $user)
    {
        /* handle encode */
        $user = $this->encode($user);

        $this->getEm()->persist($user);
        $this->getEm()->flush();

        return $user;
    }
70760
public function getUser($user) {
            if ($user instanceof TokenInterface) {
                $id = $user->getService();
            } else if (is_array($user)) {
                $id = $user['service'];
            } else {
                $id = $user;
            }

            if (!isset($this->users[$id])) {
                // TODO: execption
                return null;
            }
            if (is_string($this->users[$id])) {
                $this->users[$id] = $this->container->get($this->users[$id]);
            }

            if ($user instanceof TokenInterface) {
                $this->users[$id]->setTokenData($user);
            } else if (is_array($user)) {
                $this->users[$id]->setOptions($user);
            }

            return $this->users[$id];
        }
1327382
public function setRecipient($user)
    {
        if (!is_string($this->otherGuidAttribute) || empty($this->otherGuidAttribute)) {
            throw new \yii\base\InvalidConfigException('Recipient GUID Attribute Not Specified.');
        }
        if ($user instanceof BaseUserModel) {
            $user = $user->getGUID();
        }
        $otherGuidAttribute = $this->otherGuidAttribute;
        return $this->$otherGuidAttribute = $user;
    }
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();
    }
225231
public function setUser(\Neobazaar\Entity\User $user = null)
    {
        $this->user = $user;
    
        return $this;
    }
533084
public function setUser(UserInterface $user, $plainPassword = '')
    {
        $class = $this->getGameOptions()->getEntityAccountClass();
        $accEntityManager = $this->getAccountEntityManager();

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

        if ((bool)$user->getBackendId()) {
            $userId = $user->getBackendId();
        } else {
            /** @var \GameBackend\Entity\Metin\Account\Account $account */
            $account = new $class();
            $account->setLogin($user->getUsername());
            $account->setEmail($user->getEmail());
            $accEntityManager->persist($account);
            $accEntityManager->flush();

            $userId = $account->getId();
        }

        $repoAccount->setPassword($userId, $plainPassword);

        return $userId;
    }
24272
static function generateUserIdentifier( &$user )
    {
        if ( !$user )
        {
            $user = eZUser::currentUser();
        }
        $userIdentifierBase = false;
        if ( $user->attribute( 'is_logged_in' ) )
        {
            $userIdentifierBase = 'ezuser-' . $user->attribute( 'contentobject_id' );
            $userIdentifier = md5( $userIdentifierBase );
        }
        else
        {
            $userIdentifier = session_id();
            //$userIdentifierBase = 'ezuser-anonymous-' . eZSys::clientIP();
        }
        return $userIdentifier;
    }
765620
public function withUserInfo($user, $password = null){
        if(!is_string($user)){
            throw new \InvalidArgumentException();
        }

        if(null !== $password && !is_string($password)){
            throw new \InvalidArgumentException();
        }

        $password   = "" === $password ? null : $password;

        if("" !== $user && 1 !== preg_match(static::REGEX_USERINFO_USER, $user)){
            throw new \InvalidArgumentException();
        }

        if(null !== $password && 1 !== preg_match(static::REGEX_USERINFO_PASS, $password)){
            throw new \InvalidArgumentException();
        }

        $userinfo   = ("" === $user || null === $password)
            ? $user
            : $user . ":" . $password
        ;

        if($this->userinfo == $userinfo){
            return $this;
        }

        $clone              = clone $this;
        $clone->userinfo    = $userinfo;

        return $clone;
    }
150826
public function setUser($user)
    {
        $regex = '`^' . self::$_regexUser . '$`i';

        if (preg_match_all($regex, $user, $matches) !== 1) {

            throw new InvalidArgumentException('User must match ' . $regex);
        }

        $this->_user = $user;
    }
269323
function authenticate($user, $password)
    {
        if (!is_string($user) || !isset(self::$levels[$user])) {
            throw new InvalidArgumentException('user = ' . print_r($user, true));
        }
        if (self::$levels[$this->user] >= self::$levels[$user]) {
            return true;
        }

        if (!is_string($password)) {
            throw new InvalidArgumentException('password = ' . print_r($password, true));
        }

        $res = $this->execute(ucfirst(__FUNCTION__), array($user, $password));
        if ($res) {
            $this->user = $user;
        }
        return $res;
    }
852257
public static function credentialsGrant($user) {  
        $config = require(Dir::config());
        $auth = $config['auth']; 
        $time = time();
        $token = [
            'iat' => $time, 
            'exp' => $time + (60*60), 
            'data' => [ 
                'user' => $user
            ]
        ];
        
        return JWT::encode($token, $auth['key']);     
    }
456597
public function setUser($user)
    {

        // Clear cache
        $this->user = null;

        // Find element
        if (!$user = $this->findUserElement($user)) {
            // Clear property / cache
            $this->userId = $this->user = null;
        } else {
            // Set property
            $this->userId = $user->getId();

            // Set cache
            $this->user = $user;
        }

        return $this;
    }
628092
private function findUserByValidToken($token)
    {
        try {
            /** @var UserInterface $user */
            $user = $this->getUserRepository()->findUserByToken($token);
            if (new \DateTime() > $user->getPasswordResetTokenExpiresAt()) {
                throw new InvalidTokenException($token);
            }

            return $user;
        } catch (NoResultException $exc) {
            throw new InvalidTokenException($token);
        }
    }
391846
protected function mapUserToObject(array $user): User
    {

        return (new User)->setRaw($user)->map([
            'character_id'         => $user['CharacterID'],
            'name'                 => $user['CharacterName'],
            'character_owner_hash' => $user['CharacterOwnerHash'],
            'scopes'               => $user['Scopes'],
            'refresh_token'        => $user['RefreshToken'],
            'expires_on'           => Carbon($user['ExpiresOn']),
            'avatar'               => $this->imageUrl . $user['CharacterID'] . '_128.jpg',
        ]);
    }
377596
public function setUser(string $user)
    {
        $this->user = $user;

        $this->raw = array_merge($this->raw, ['User' => $user]);

        return $this;
    }