@param User    $user
@param Request $request
@param array   $criteria

@return null|LikeAction
490514
public function getLikeBy(User $user, Request $request = null, $criteria = [])
    {
        $criteria = $this->getCriteriaFromRequest($request, $user, $criteria);

        return $this->likeActionRepository->findOneBy($criteria);
    }
1187365
public function logConnectPlatformListCsvAction(User $user, Request $request)
    {
        $this->checkAdminToolAccess();
        $isAdmin = $this->authorization->isGranted('ROLE_ADMIN');
        $query = $request->query->all();
        $filters = isset($query['filters']) ? $query['filters'] : [];
        $sortBy = null;

        if (isset($query['sortBy'])) {
            $direction = '-' === substr($query['sortBy'], 0, 1) ? -1 : 1;
            $property = 1 === $direction ? $query['sortBy'] : substr($query['sortBy'], 1);
            $sortBy = ['property' => $property, 'direction' => $direction];
        }
        if (!$isAdmin) {
            $filters['organizations'] = array_map(function (Organization $organization) {
                return $organization->getUuid();
            }, $user->getAdministratedOrganizations()->toArray());
        }
        $downloadDate = date('Y-m-d_H-i-s');

        return new StreamedResponse(function () use ($filters, $sortBy) {
            $this->logConnectManager->exportConnectionsToCsv(LogConnectPlatform::class, $filters, $sortBy);
        }, 200, [
            'Content-Type' => 'application/force-download',
            'Content-Disposition' => 'attachment; filename="connection_time_platform_'.$downloadDate.'.csv"',
        ]);
    }
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);
    }
713963
public function updateRoles(Request $request, User $user)
    {
        $this->authorize('roles', $user);

        $roles = Role::all();

        foreach ($roles as $role) {
            if (array_key_exists($role->id, $request->all())) {
                $role->addUser($user);
            } else {
                $role->deleteUser($user);
            }
        }

        return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_roles_updated', ['id' => $user->id]));
    }
1273014
public function resetPasswordAction(Request $request, User $user)
    {
        $form = $this->createFormBuilder(null, $this->getDefaultFormOptions($request, $user->getId()))->getForm();

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $this->get(UserManagerInterface::class)->requestNewPassword($user);
            $this->saveEntity($user);

            if ($request->isXmlHttpRequest()) {
                return array_merge(
                    $this->getViewParameters($request, $form, $user),
                    [
                        'dataId' => $user->getId(),
                        'success' => 1,
                    ]
                );
            }

            return $this->redirectToAction('list');
        }

        return $this->renderAction(
            array_merge(
                $this->getViewParameters($request, $form, $user),
                [
                    'dataId' => $user->getId(),
                ]
            )
        );
    }
1138497
public function findUserRoleByUser(User $user, $executeQuery = true)
    {
        $username = $user->getUsername();
        $roleName = 'ROLE_USER_' . strtoupper($username);

        $dql = '
            SELECT r
            FROM Claroline\CoreBundle\Entity\Role r
            WHERE r.type = :type
            AND r.name = :name
            AND r.translationKey = :key
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('type', Role::USER_ROLE);
        $query->setParameter('name', $roleName);
        $query->setParameter('key', $username);

        return $executeQuery ? $query->getOneOrNullResult() : $query;
    }
886385
public function enableAction(Request $request, $userClass)
    {
        $confirmationToken = $request->query->get('token');
        if (null === $confirmationToken) {
            return new JsonResponse(null, 404);
        }

        try {
            $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle(
                new EnableUserCommand($confirmationToken)
            );

            return new JsonResponse();
        } catch (UserTokenNotFoundException $exception) {
            return new JsonResponse(
                sprintf(
                    'The "%s" confirmation token does not exist',
                    $confirmationToken
                ),
                400
            );
        }
    }
369259
public function updateUser($userId, Request $request)
    {
        $user = $this->userService->loadUser($userId);

        $updateStruct = $this->inputDispatcher->parse(
            new Message(
                array(
                    'Content-Type' => $request->headers->get('Content-Type'),
                    // @todo Needs refactoring! Temporary solution so parser has access to URL
                    'Url' => $request->getPathInfo(),
                ),
                $request->getContent()
            )
        );

        if ($updateStruct->sectionId !== null) {
            $section = $this->sectionService->loadSection($updateStruct->sectionId);
            $this->sectionService->assignSection(
                $user->getVersionInfo()->getContentInfo(),
                $section
            );
        }

        $updatedUser = $this->userService->updateUser($user, $updateStruct->userUpdateStruct);
        $updatedContentInfo = $updatedUser->getVersionInfo()->getContentInfo();
        $mainLocation = $this->locationService->loadLocation($updatedContentInfo->mainLocationId);
        $contentType = $this->contentTypeService->loadContentType($updatedContentInfo->contentTypeId);

        return new Values\RestUser(
            $updatedUser,
            $contentType,
            $updatedContentInfo,
            $mainLocation,
            $this->contentService->loadRelations($updatedUser->getVersionInfo())
        );
    }
522437
protected function scopeVisibleTo(Builder $query, User $user = null)
    {
        if ($user !== null && !$user->isAdmin()) {
            $query->whereIsHidden(0);
        }

        return $query;
    }
125726
public function findNonPlatformRolesForUser(User $user, $executeQuery = true)
    {
        $dql = '
            SELECT r
            FROM Claroline\CoreBundle\Entity\Role r
            JOIN r.workspace w
            JOIN r.users u
            WHERE w.creator != :user
            AND u = :user
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('user', $user);

        return $executeQuery ? $query->getResult() : $query;
    }
283686
public function show(Request $request, $user)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin']);

        // Return view with user object
        $user = User::findOrFail($user);
        return view('user::show', ['user' => $user]);
    }
880467
public function deleteAction(Request $request, $userId)
    {
        $successorUserId = $request->request->get('successor');

        $userManager = $this->get('phlexible_user.user_manager');

        $successorUser = $userManager->find($successorUserId);
        $user = $userManager->find($userId);

        $userManager->deleteUserWithSuccessor($user, $successorUser);

        $this->get('phlexible_message.message_poster')
            ->post(UsersMessage::create('User "'.$user->getUsername().'" deleted.'));

        return new ResultResponse(true);
    }
1312122
public function byInvitationAction(Request $request, $userClass)
    {
        $invitationToken = $request->query->get('token');
        try {
            // we need to know if the invitation token given exists in
            // database, in case that it isn't, it throws 404.
            $user = $this->get('bengor_user.' . $userClass . '.by_invitation_token_query')->__invoke(
                new UserOfInvitationTokenQuery($invitationToken)
            );
        } catch (UserDoesNotExistException $exception) {
            return new JsonResponse(null, 404);
        } catch (UserTokenExpiredException $exception) {
            return new JsonResponse(null, 404);
        } catch (\InvalidArgumentException $exception) {
            return new JsonResponse(null, 404);
        }

        $form = $this->get('form.factory')->createNamedBuilder('', SignUpByInvitationType::class, null, [
            'roles'            => $this->getParameter('bengor_user.' . $userClass . '_default_roles'),
            'invitation_token' => $invitationToken,
            'csrf_protection'  => false,
        ])->getForm();

        $form->handleRequest($request);
        if ($form->isValid()) {
            $commandBus = $this->get('bengor_user.' . $userClass . '.api_command_bus');

            try {
                $commandBus->handle(
                    $form->getData()
                );
                $commandBus->handle(
                    new LogInUserCommand(
                        $user['email'],
                        $form->getData()->password()
                    )
                );
            } catch (UserDoesNotExistException $exception) {
                return new JsonResponse(null, 404);
            } catch (UserInactiveException $exception) {
                return new JsonResponse(null, 404);
            } catch (UserPasswordInvalidException $exception) {
                return new JsonResponse('Bad credentials', 400);
            } catch (UserAlreadyExistException $exception) {
                return new JsonResponse('Bad credentials', 400);
            }
            $token = $this->get('lexik_jwt_authentication.encoder.default')->encode(['email' => $user['email']]);

            return new JsonResponse(['token' => $token]);
        }

        return new JsonResponse(FormErrorSerializer::errors($form), 400);
    }
375163
public static function user(Request $request)
    {
        try {

            $data = self::token($request);
            $repository = db::em()->getRepository(cfg::USER_ENTITY);
            return $repository->find($data->data->id ?? 0);
        } catch (HeaderWithoutAuthorizationException $ex) {
            return false;
        }
    }
938510
public function getAllAction(Request $request, User $loggedUser)
    {
        $this->checkPortfolioToolAccess();

        $widgets = $this->getWidgetsManager()->getWidgets($loggedUser);

        $data = [];

        foreach ($widgets as $widget) {
            $data[] = $this->getWidgetsManager()->getWidgetData($widget);
        }

        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }
875098
protected function login(Request $request, User $user)
    {
        impersonate()->login($user);

        // if redirect url in request
        if ($request->has('redirect_to')) {
            return redirect($request->get('redirect_to'));
        }

        return back();
    }
386278
public function edit(Request $request, $user)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin']);

        // Return view with user object
        $user = User::findOrFail($user);
        return view('user::edit', ['user' => $user]);
    }