Adds :target to :user's block list. :user is the authenticated user and :target is user to be blocked. Returns a blocks object.
Authenticated, required scope: user_blocks_edit

@param      $user
@param      $target
@param null $token

@return json
341121
public function putBlock($user, $target, $token = null)
    {
        $token = $this->getToken($token);

        $blocksApi = new Blocks($token);

        return $blocksApi->putBlock($user, $target);
    }
1320871
public function getUserAssertionsAction(Request $request, User $user)
    {
        $assertions = $this->finder->search(Assertion::class, array_merge(
            $request->query->all(),
            ['hiddenFilters' => ['recipient' => $user->getUuid()]]
        ));

        return new JsonResponse($assertions);
    }
643412
public function blocks($login, $token = null)
    {
        $token = $this->getToken($token);

        $blocksApi = new Blocks($token);

        return $blocksApi->blocks($login);
    }
53950
public function updateRememberToken(UserContract $user, $token)
    {
        $this->conn->table($this->table)
                ->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
                ->update([$user->getRememberTokenName() => $token]);
    }
172935
public function addTarget(Target $target, string $name = null)
    {
        if ($name === null) {
            $this->_targets[] = $target;
        } else {
            $this->_targets[$name] = $target;
        }
    }
907841
protected function sendVerifyEmailNotification($user, string $token) : array
  {
    return Notification::make(new MustVerifyEmail($user->email, $token));
  }
61678
private function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();
        if (!$user instanceof UserInterface) {
            return $token;
        }

        if (null !== $this->logger) {
            $this->logger->debug(sprintf('Reloading user from user provider.'));
        }

        foreach ($this->userProviders as $provider) {
            try {
                $refreshedUser = $provider->refreshUser($user);
                $token->setUser($refreshedUser);

                if (null !== $this->logger) {
                    $this->logger->debug(sprintf('Username "%s" was reloaded from user provider.', $refreshedUser->getUsername()));
                }

                return $token;
            } catch (UnsupportedUserException $unsupported) {
                // let's try the next user provider
            } catch (UsernameNotFoundException $notFound) {
                if (null !== $this->logger) {
                    $this->logger->warning(sprintf('Username "%s" could not be found.', $notFound->getUsername()));
                }

                return;
            }
        }

        throw new \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user)));
    }
1190648
public function setTarget($target)
    {
        $this->removeTarget();

        if ($target = (string) $target) {
            $mark = mb_substr($target, 0, 1);
            $to = mb_substr($target, 1);

            if ($mark === '@') {
                $this->setUser($to);
            } elseif ($mark === '#') {
                $this->setChannel($to);
            } else {
                $this->setChannel($target);
            }
        }

        return $this;
    }
349851
public function update(ProfileRequest $request, User $user)
    {
        event(new ProfileWasUpdated($request));

        if ($request->wantsJson()) {
            return $this->respondsWithSuccess('ok');
        }

        return back();
    }
914092
public function update(User $user, Block $block)
    {
        if ($block->author->id === $user->id) {
            return true;
        }
        return $user->hasPermission('block-update');
    }
73144
protected function setAuthenticationHeader($response, $token = null)
    {
        $token = $token ?: $this->auth->refresh();
        $response->headers->set('Authorization', 'Bearer '.$token);

        return $response;
    }
271206
protected function getImpersonatingUserFromRole($token, $user = null)
    {
        foreach ($token->getRoles() as $role) {
            if ($role instanceof SwitchUserRole) {
                $user = $role->getSource()->getUser();
                break;
            }
        }

        return $user;
    }
408440
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        if ($request->isXmlHttpRequest()) {
            /** @var User $user */
            $user = $token->getUser();
            $roles = $token->getRoles();
            $outputRoles = array();

            foreach ($roles as $role) {
                $outputRoles[] = $this->translator->trans('roles.' . $role->getRole(), array(), 'CodeLoversAngularBundle');
            }

            $output = $this->generator->getUserData($request, $token);

            // notify listeners to allow output modification
            $event = new LoginEvent($user);
            $event->setOutput($output);

            $this->dispatcher->dispatch(AuthEvents::LOGIN_SUCCESS, $event);

            return new JsonResponse($event->getOutput());
        } else {
            if ($targetPath = $request->getSession()->get('_security.target_path')) {
                $url = $targetPath;
            } else {
                $url = $this->getDefaultUrl();
            }

            return new RedirectResponse($url);
        }
    }
913830
public function userSubscriptionChannel($user, $channel, $token = null)
    {
        $token = $this->getToken($token);

        $subscriptionsAPI = new Subscriptions($token);

        return $subscriptionsAPI->userSubscriptionChannel($user, $channel);
    }
937325
public function blockUser(UserInterface $user, $expire, $reason, $creator = null)
    {
        $class = $this->entityOptions->getUserBlock();
        /** @var UserBlockEntity $userBlock */
        $userBlock = new $class;
        $userBlock->setUser($user);
        $userBlock->setCreator($creator);
        $userBlock->setReason($reason);
        $userBlock->setExpire($expire);

        $this->blockUserWithEntity($userBlock);
    }
135936
public void blockUser(Integer targetUserId) throws IOException {

        String tailUrl = GitlabUser.USERS_URL + "/" + targetUserId + GitlabUser.BLOCK_URL;

        retrieve().method(POST).to(tailUrl, Void.class);
    }
630666
private function checkView(TokenInterface $token, User $user)
    {
        return $this->isOrganizationManager($token, $user) ?
              VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
    }