Bolt\AccessControl\Login::loginCheckAuthtoken PHP Метод

loginCheckAuthtoken() защищенный Метод

Attempt to login a user via the bolt_authtoken cookie.
protected loginCheckAuthtoken ( string $authCookie, Bolt\Events\AccessControlEvent $event ) : boolean
$authCookie string
$event Bolt\Events\AccessControlEvent
Результат boolean
    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->getUsername(), $userTokenEntity->getSalt());
        if ($checksalt === $userTokenEntity->getToken()) {
            if (!($userEntity = $this->getUserEntity($userTokenEntity->getUsername()))) {
                $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'));
            $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;
    }