Log into the identity-store handlers attached to this request filter

@param Member $member
@param bool $persistent
@param HTTPRequest $request
173832
public function logIn(Member $member, $persistent = false, HTTPRequest $request = null)
    {
        $member->beforeMemberLoggedIn();

        foreach ($this->getHandlers() as $handler) {
            $handler->logIn($member, $persistent, $request);
        }

        Security::setCurrentUser($member);
        $member->afterMemberLoggedIn();
    }
459320
public function handleLinkRequest(LoginRequest $request, $userId)
    {
        $socialLogin = $this->socialLoginMapper->findByProviderUserId(
            $request->getProvider(),
            $request->getProviderUserId()
        );

        if ($socialLogin) {
            throw new LinkedAccountExistsException;
        }

        $user = $this->userService->findById($userId);

        if (! $user) {
            throw new OutOfBoundsException('Account not found', self::EXCEPTION_ACCOUNT_NOT_FOUND);
        }

        $socialLoginEntity = new SocialLoginEntity;
        $socialLoginEntity->setUserId($user->getId())
            ->setProvider($request->getProvider())
            ->setProviderUserId($request->getProviderUserId())
            ->setAccessToken($request->getAccessToken())
            ->setAccessTokenExpires($request->getAccessTokenExpires())
            ->setRefreshToken($request->getRefreshToken());

        $socialLogin = $this->socialLoginMapper->persist($socialLoginEntity);

        return $this->handleLogin($user, $request);
    }
755408
protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->route('soda.login');
    }
1142361
private function login(Request $request)
    {
        $user = $this->loginProvider->authenticate($request);
        if (null !== $user) {
            try {
                $token = $user->createToken($this->tokenSalt);
                $this->tokenStore->store($request, $token, $user);
                return $user;
            } catch (\Exception $e) {
                throw new InternalAuthProviderException(
                        'Error while trying to store new token for user: ' . $e->getMessage(),
                        $e
                );
            }
        }

        return null;
    }
919165
public function onMethodVerificationSuccess(Member $member, $method)
    {
        $this->getAuditLogger()->info(
            sprintf(
                '"%s" (ID: %s) successfully verified using MFA method',
                $member->Email ?: $member->Title,
                $member->ID
            ),
            ['method' => get_class($method)]
        );
    }
1233667
public function onMethodVerificationFailure(Member $member, $method)
    {
        $context = [
            'method' => get_class($method),
        ];
        if ($lockOutAfterCount = $member->config()->get('lock_out_after_incorrect_logins')) {
            // Add information about how many attempts have been made
            $context['attempts'] = $member->FailedLoginCount;
            $context['attempt_limit'] = $lockOutAfterCount;
        }

        $this->getAuditLogger()->info(sprintf(
            '"%s" (ID: %s) failed to verify using MFA method',
            $member->Email ?: $member->Title,
            $member->ID
        ), $context);
    }
286786
public function rememberCheckoutUuids(PersistEvent $event)
    {
        if (!$this->support($event->getDocument())) {
            return;
        }

        $this->checkoutUuids[] = $event->getNode()->getIdentifier();
    }
522682
private function keepCurrentLocator(Request $request)
    {
        // Ensure a location is not already set, to avoid overwriting it.
        if (!@$_COOKIE[self::LOCATOR_COOKIE_NAME]) {
            $currentUrl = $request->getCurrentUrl();
            // Do not keep identity URLs.
            if (!preg_match('#/identity.+#', $currentUrl)) {
                setcookie(
                    self::LOCATOR_COOKIE_NAME,
                    $currentUrl,
                    time() + 300 // Keep it for 5 minutes.
                );
                Logger::get()->debug('Current locator stored: ' . $currentUrl);
            }
        }
    }
54520
public function authenticate(Request $request)
    {
        if (Auth::user()) {
            return false;
        }

        $this->checkForToken($request);

        try {
            if (!JWTAuth::parseToken()->authenticate()) {
                throw new UnauthorizedHttpException('jwt-auth', 'User not found');
            }
        } catch (TokenExpiredException $e) {
            // If the token is expired, then it will be refreshed and added to the headers
            try {
                return Auth::refresh();
            } catch (TokenExpiredException $e) {
                throw new UnauthorizedHttpException('jwt-auth', 'Refresh token has expired.');
            }
        } catch (TokenBlacklistedException $e) {
            throw new TokenBlacklistedException($e->getMessage(), 401);
        } catch (JWTException $e) {
            throw new UnauthorizedHttpException('jwt-auth', $e->getMessage(), $e, $e->getCode());
        }
    }
1271147
public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
    {
        /**
         * @var ValidationResult $message
         * @var Member|MemberExtension $member
         */
        $member = $this->checkLogin($data, $request, $message);

        if (!$member) {
            return $this->redirectBack();
        }

        // If we're in grace period, continue to the parent
        if ($member->isInGracePeriod()) {
            return parent::doLogin($data, $form, $request);
        }

        if ($message->isValid()) {
            /** @var Session $session */
            $session = $request->getSession();
            $session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.MemberID', $member->ID);
            $session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.Data', $data);
            if (!empty($data['BackURL'])) {
                $session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.BackURL', $data['BackURL']);
            }

            return $this->redirect($this->link('verify'));
        }

        return $this->redirectBack();
    }
456362
public function login(UserInterface $user, $remember = false)
	{
		if ( ! $user->isActivated())
		{
			$login = $user->getLogin();
			throw new UserNotActivatedException("Cannot login user [$login] as they are not activated.");
		}

		$this->user = $user;

		// Create an array of data to persist to the session and / or cookie
		$toPersist = array($user->getId(), $user->getPersistCode());

		// Set sessions
		$this->session->put($toPersist);

		if ($remember)
		{
			$this->cookie->forever($toPersist);
		}

		// The user model can attach any handlers
		// to the "recordLogin" event.
		$user->recordLogin();
	}
706726
protected function registered(Request $request, $user)
    {
        $profile = new Profile();
        $profile->user_id = $user->id;
        $profile->save();
    }
65823
public void addMember(JsonNode member) {
        User user = api.getOrCreateUser(member.get("user"));
        members.put(user.getId(), user);
        if (member.hasNonNull("nick")) {
            nicknames.put(user.getId(), member.get("nick").asText());
        }
        if (member.hasNonNull("mute")) {
            setMuted(user.getId(), member.get("mute").asBoolean());
        }
        if (member.hasNonNull("deaf")) {
            setDeafened(user.getId(), member.get("deaf").asBoolean());
        }

        for (JsonNode roleIds : member.get("roles")) {
            long roleId = Long.parseLong(roleIds.asText());
            getRoleById(roleId).map(role -> ((RoleImpl) role)).ifPresent(role -> role.addUserToCache(user));
        }

        joinedAtTimestamps.put(user.getId(), OffsetDateTime.parse(member.get("joined_at").asText()).toInstant());

        synchronized (readyConsumers) {
            if (!ready && members.size() == getMemberCount()) {
                ready = true;
                readyConsumers.forEach(consumer -> consumer.accept(this));
                readyConsumers.clear();
            }
        }
    }
304216
public function createAndLoginAction(Request $request)
    {
        //there is a little bit of computation involved here (ie, do we need to validate the account or stuff like this)
        //but keep it easy for now because an other route could be relevant
        $selfLog = true;
        $autoOrganization = $this->container
            ->get('claroline.config.platform_config_handler')
            ->getParameter('force_organization_creation');

        $organizationRepository = $this->container->get('claroline.persistence.object_manager')
            ->getRepository('ClarolineCoreBundle:Organization\Organization');

        //step one: creation the organization if it's here. If it exists, we fetch it.
        $data = $this->decodeRequest($request);

        if ($selfLog && 'anon.' === $this->container->get('security.token_storage')->getToken()->getUser()) {
            $this->options['create'][] = Options::USER_SELF_LOG;
        }

        $organization = null;

        if ($autoOrganization) {
            //try to find orga first
            //first find by vat
            if (isset($data['mainOrganization'])) {
                if (isset($data['mainOrganization']['vat']) && null !== $data['mainOrganization']['vat']) {
                    $organization = $organizationRepository
                      ->findOneBy(['vat' => $data['mainOrganization']['vat']]);
                //then by code
                } else {
                    $organization = $organizationRepository
                      ->findOneBy(['code' => $data['mainOrganization']['code']]);
                }
            }

            if (!$organization && isset($data['mainOrganization'])) {
                $organization = $this->crud->create(
                    'Claroline\CoreBundle\Entity\Organization\Organization',
                    $data['mainOrganization']
                );
            }

            //error handling
            if (is_array($organization)) {
                return new JsonResponse($organization, 400);
            }
        }

        $user = $this->crud->create(
            User::class,
            $this->decodeRequest($request),
            array_merge($this->options['create'], [Options::VALIDATE_FACET])
        );

        //error handling
        if (is_array($user)) {
            return new JsonResponse($user, 400);
        }

        if ($organization) {
            $this->crud->replace($user, 'mainOrganization', $organization);
        }

        return new JsonResponse(
            $this->serializer->serialize($user, $this->options['get']),
            201
        );
    }
1090264
public function loginAction(Request $request)
    {
        /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
        $session = $request->getSession();

        $authErrorKey = Security::AUTHENTICATION_ERROR;
        $lastUsernameKey = Security::LAST_USERNAME;

        // get the error if any (works with forward and redirect -- see below)
        if ($request->attributes->has($authErrorKey)) {
            $error = $request->attributes->get($authErrorKey);
        } elseif (null !== $session && $session->has($authErrorKey)) {
            $error = $session->get($authErrorKey);
            $session->remove($authErrorKey);
        } else {
            $error = null;
        }

        if (!$error instanceof AuthenticationException) {
            $error = null; // The value does not come from the security component.
        }

        // last username entered by the user
        $lastUsername = (null === $session) ? '' : $session->get($lastUsernameKey);
        $csrfToken = $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue();

        return $this->render('EkynaAdminBundle:Security:login.html.twig', [
            'last_username' => $lastUsername,
            'error'         => $error,
            'token'         => $csrfToken,
        ]);
    }
349289
public function createSessionFromRequest($request, $resolver)
    {
        if (!$this->isRestController($resolver)) {
            return false;
        }
        /** @var SessionBuilder $builder */
        foreach ($this->getSessionBuilders() as $builder) {
            if ($builder->isApplicable($request)) {
                return $this->startSession($builder->getSession($request));
            }
        }
        throw new LoginFailedException(array('Request cannot be authenticated.'));
    }
1208055
private void putInCache(MembershipImpl membership)
   {
      cache.put(cache.getMembershipKey(membership), membership, CacheType.MEMBERSHIP);
   }