protected function loginCheckAuthtoken($authCookie, AccessControlEvent $event)
    {
        if (!$userTokenEntity = $this->getRepositoryAuthtoken()->getToken($authCookie, $this->getClientIp(), $this->getClientUserAgent())) {
            $this->flashLogger->error(Trans::__('general.phrase.error-login-invalid-parameters'));
            $this->dispatcher->dispatch(AccessControlEvents::LOGIN_FAILURE, $event->setReason(AccessControlEvents::FAILURE_INVALID));

            return false;
        }

        $checkSalt = $this->getAuthToken($userTokenEntity->getUserId(), $userTokenEntity->getSalt());
        if ($checkSalt === $userTokenEntity->getToken()) {
            if (!$userEntity = $this->getUserEntity($userTokenEntity->getUserId())) {
                $this->dispatcher->dispatch(AccessControlEvents::LOGIN_FAILURE, $event->setReason(AccessControlEvents::FAILURE_INVALID));

                return false;
            }

            $cookieLifetime = (int) $this->cookieOptions['lifetime'];
            $userTokenEntity->setValidity(Carbon::create()->addSeconds($cookieLifetime));
            $userTokenEntity->setLastseen(Carbon::now());
            $this->getRepositoryAuthtoken()->save($userTokenEntity);
            $this->flashLogger->success(Trans::__('general.phrase.session-resumed-colon'));

            // Ensure we have a CSRF token, to prevent timing issues when the user opens multiple pages at once.
            $this->csrfTokenManager->getToken('content_edit');

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

            return $this->loginFinish($userEntity);
        }

        $this->dispatcher->dispatch(AccessControlEvents::LOGIN_FAILURE, $event->setReason(AccessControlEvents::FAILURE_INVALID));
        $this->systemLogger->alert(sprintf('Attempt to login with an invalid token from %s', $this->getClientIp()), ['event' => 'security']);

        return false;
    }
protected function loginCheckAuthtoken($authCookie, AccessControlEvent $event)
    {
        if (!$userTokenEntity = $this->getRepositoryAuthtoken()->getToken($authCookie, $this->getClientIp(), $this->getClientUserAgent())) {
            $this->flashLogger->error(Trans::__('general.phrase.error-login-invalid-parameters'));
            $this->dispatcher->dispatch(AccessControlEvents::LOGIN_FAILURE, $event->setReason(AccessControlEvents::FAILURE_INVALID));

            return false;
        }

        $checkSalt = $this->getAuthToken($userTokenEntity->getUserId(), $userTokenEntity->getSalt());
        if ($checkSalt === $userTokenEntity->getToken()) {
            if (!$userEntity = $this->getUserEntity($userTokenEntity->getUserId())) {
                $this->dispatcher->dispatch(AccessControlEvents::LOGIN_FAILURE, $event->setReason(AccessControlEvents::FAILURE_INVALID));

                return false;
            }

            $cookieLifetime = (int) $this->cookieOptions['lifetime'];
            $userTokenEntity->setValidity(Carbon::create()->addSeconds($cookieLifetime));
            $userTokenEntity->setLastseen(Carbon::now());
            $this->getRepositoryAuthtoken()->save($userTokenEntity);
            $this->flashLogger->success(Trans::__('general.phrase.session-resumed-colon'));

            // Ensure we have a CSRF token, to prevent timing issues when the user opens multiple pages at once.
            $this->csrfTokenManager->getToken('content_edit');

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

            return $this->loginFinish($userEntity);
        }

        $this->dispatcher->dispatch(AccessControlEvents::LOGIN_FAILURE, $event->setReason(AccessControlEvents::FAILURE_INVALID));
        $this->systemLogger->alert(sprintf('Attempt to login with an invalid token from %s', $this->getClientIp()), ['event' => 'security']);

        return false;
    }
protected function loginCheckAuthtoken ( $ authCookie , AccessControlEvent $ event ) { if ( ! $ userTokenEntity = $ this -> getRepositoryAuthtoken ( ) -> getToken ( $ authCookie , $ this -> getClientIp ( ) , $ this -> getClientUserAgent ( ) ) ) { $ this -> flashLogger -> error ( Trans :: __ ( 'general.phrase.error-login-invalid-parameters' ) ) ; $ this -> dispatcher -> dispatch ( AccessControlEvents :: LOGIN_FAILURE , $ event -> setReason ( AccessControlEvents :: FAILURE_INVALID ) ) ; return false ; } $ checkSalt = $ this -> getAuthToken ( $ userTokenEntity -> getUserId ( ) , $ userTokenEntity -> getSalt ( ) ) ; if ( $ checkSalt === $ userTokenEntity -> getToken ( ) ) { if ( ! $ userEntity = $ this -> getUserEntity ( $ userTokenEntity -> getUserId ( ) ) ) { $ this -> dispatcher -> dispatch ( AccessControlEvents :: LOGIN_FAILURE , $ event -> setReason ( AccessControlEvents :: FAILURE_INVALID ) ) ; return false ; } $ cookieLifetime = ( int ) $ this -> cookieOptions [ 'lifetime' ] ; $ userTokenEntity -> setValidity ( Carbon :: create ( ) -> addSeconds ( $ cookieLifetime ) ) ; $ userTokenEntity -> setLastseen ( Carbon :: now ( ) ) ; $ this -> getRepositoryAuthtoken ( ) -> save ( $ userTokenEntity ) ; $ this -> flashLogger -> success ( Trans :: __ ( 'general.phrase.session-resumed-colon' ) ) ; // Ensure we have a CSRF token, to prevent timing issues when the user opens multiple pages at once. $ this -> csrfTokenManager -> getToken ( 'content_edit' ) ; $ this -> dispatcher -> dispatch ( AccessControlEvents :: LOGIN_SUCCESS , $ event -> setDispatched ( ) ) ; return $ this -> loginFinish ( $ userEntity ) ; } $ this -> dispatcher -> dispatch ( AccessControlEvents :: LOGIN_FAILURE , $ event -> setReason ( AccessControlEvents :: FAILURE_INVALID ) ) ; $ this -> systemLogger -> alert ( sprintf ( 'Attempt to login with an invalid token from %s' , $ this -> getClientIp ( ) ) , [ 'event' => 'security' ] ) ; return false ; }
Attempt to login a user via the bolt_authtoken cookie.

@param string             $authCookie
@param AccessControlEvent $event

@return bool
Attempt to login a user via the bolt_authtoken cookie .