Returns user configuration from the repository. It will be stored in repository if it has not been stored yet.

@param User $user
@param AreaContract $area
@return \Antares\Modules\TwoFactorAuth\Contracts\UserConfig
3660
protected function getUserConfig(User $user, AreaContract $area)
    {
        $provider   = $this->twoFactorProvidersService->getEnabledInArea($area);
        $userConfig = $this->userConfigRepository->findByUserIdAndProviderId($user->id, $provider->getId());

        if ($userConfig) {
            return $userConfig;
        }

        $data = [
            'user_id'     => $user->id,
            'provider_id' => $provider->getId(),
        ];

        return $this->userConfigRepository->save($data);
    }
37642
private function roles(Response $response, User $user)
    {
        try {
            return $this->injector->getInstance(AuthorizationProvider::class)
                    ->roles($user);
        } catch (AuthProviderException $ahe) {
            $this->handleAuthProviderException($ahe, $response);
            return null;
        }
    }
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;
    }
1152162
public function setUser(User $user)
    {
        $this->user = $user;

        unset($_SESSION[self::class][$this->getConfig()->getEntityID()]['user']);

        $_SESSION[self::class][$this->getConfig()->getEntityID()]['user'] = $this->user->toArray();
        $this->setRole($this->user->getCurrentRole());
        $this->setLocalUsername($this->user->getLocalUsername());

        return $this;
    }
132304
protected function createRememberTokenIfDoesntExist(UserContract $user)
    {
        $rememberToken = $user->getRememberToken();

        if (empty($rememberToken)) {
            $this->refreshRememberToken($user);
        }
    }
128204
public function index(User $user, Collection $areaProvidersCollection)
    {
        $items = [];

        foreach ($areaProvidersCollection as $areaProviders) {
            /* @var $areaProviders AreaProviders */

            $enabled = $areaProviders->getEnabledModel();

            if (!$enabled instanceof Provider) {
                continue;
            }

            $area = $areaProviders->getArea();

            if ($enabled->isForced()) {
                $items[] = [
                    'area' => $area,
                    'line' => trans('antares/two_factor_auth::configuration.activated'),
                ];
            } elseif ($this->userProviderConfigService->hasEnabledArea($area)) {
                $url   = handles('two_factor_auth.user.configuration.disable', compact('area', 'user'));
                $attrs = [
                    'class'            => 'triggerable confirm',
                    'data-title'       => trans('antares/two_factor_auth::configuration.disable.title'),
                    'data-description' => trans('antares/two_factor_auth::configuration.disable.prompt'),
                    'data-icon'        => 'minus',
                ];

                $items[] = [
                    'area' => $area,
                    'line' => HTML::link($url, trans('antares/two_factor_auth::configuration.disable.label'), $attrs),
                ];
            } else {
                $url   = handles('two_factor_auth.user.configuration.enable', compact('area', 'user'));
                $attrs = [
                    'class'            => 'triggerable confirm',
                    'data-title'       => trans('antares/two_factor_auth::configuration.enable.title'),
                    'data-description' => trans('antares/two_factor_auth::configuration.enable.prompt'),
                    'data-icon'        => 'minus',
                ];

                $items[] = [
                    'area' => $area,
                    'line' => HTML::link($url, trans('antares/two_factor_auth::configuration.enable.label'), $attrs),
                ];
            }
        }

        return $items;
    }
922410
public function getAuthAdapter(\Gems_User_User $user, $password)
    {
        //Ok hardcoded for now this needs to be read from the userdefinition
        $configData = $this->loadConfig(array('gor_id_organization' => $user->getBaseOrganizationId()));

        $config  = array('ip'                 => $configData['grcfg_ip'],
                         'authenticationport' => $configData['grcfg_port'],
                         'sharedsecret'       => $configData['grcfg_secret']);

        //Unset empty
        foreach($config as $key=>$value) {
            if (empty($value)) {
                unset($config[$key]);
            }
        }
        $adapter = new \Gems_User_Adapter_Radius($config);

        $adapter->setIdentity($user->getLoginName())
                ->setCredential($password);

        return $adapter;
    }
1340706
public function getAuthAdapter(\Gems_User_User $user, $password)
    {
        $config = $this->project->getLdapSettings();

        $adapter = new LdapAdapter();

        // \MUtil_Echo::track($config);
        foreach ($config as $server) {
            $adapter->setOptions([$server]);

            if (isset($server['accountDomainNameShort'])) {
                $userName = $server['accountDomainNameShort'] . '\\' . $user->getLoginName();
            } else {
                $userName = $user->getLoginName();
            }

            $adapter->setUsername($userName)
                    ->setPassword($password);
        }

        return $adapter;
    }
430438
private function createEditForm(User $user)
    {
        $form = $this->createForm(new UserType(), $user, array(
            'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
1296287
public function getWorkspaceRolesForUser(User $user, Workspace $workspace)
    {
        return $this->roleRepo->findWorkspaceRolesForUser($user, $workspace);
    }
1068672
public function addUser(User $user)
    {
        if (!$this->users->contains($user)) {
            $this->users->add($user);
        }

        return $this;
    }
611425
public function findByUser(User $user, $executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('p')
            ->andWhere('p.user = :userId')
            ->setParameter('userId', $user->getId())
        ;

        return $executeQuery ? $queryBuilder->getQuery()->getResult() : $queryBuilder->getQuery();
    }
1187980
private function createRegisterForm(User $user)
    {
        $form = $this->createForm(new UserRegisterType(), $user, array(
            'action' => $this->generateUrl('amulen_user_register_do'),
            'method' => 'POST',
        ));

        $form->add('submit', 'submit', array('label' => 'Register'));

        return $form;
    }
1187750
public function actingAs(UserContract $user, $driver = null)
    {
        $this->be($user, $driver);

        return $this;
    }
1105301
public function getResourceUserPermission(ResourceInterface $resource, UserInterface $user)
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId AND r.user=:user')
            ->setParameter('resourceClass', $resource->getClass())
            ->setParameter('resourceId', $resource->getId())
            ->setParameter('user', $user)
            ->getQuery();

        return $query->getOneOrNullResult();
    }
24492
public function disable(UserConfigurationListener $listener, User $user, AreaContract $area)
    {
        try {
            $userConfig = $this->getUserConfig($user, $area);

            $this->userConfigRepository->markAsDisabledById($userConfig->id);

            $msg = trans('antares/two_factor_auth::configuration.responses.disable.success', ['area' => $area->getLabel()]);

            return $listener->disableSuccess($msg);
        } catch (Exception $e) {
            Log::emergency($e);

            $msg = trans('antares/two_factor_auth::configuration.responses.disable.fail', ['area' => $area->getLabel()]);

            return $listener->disableFailed($msg);
        }
    }
381481
public function setUser(AuthenticatableContract $user)
    {
        $this->user = $user;

        $this->loggedOut = false;

        $this->fireAuthenticatedEvent($user);

        return $this;
    }