concrete/src/User/Login/LoginAttemptService.php
public function remainingAttempts($username)
    {
        $config = $this->config->get('concrete.user.deactivation.authentication_failure');

        $allowed = (int) array_get($config, 'amount', 0);
        $duration = (int) array_get($config, 'duration', 0);
        $after = Carbon::now('UTC')->subSeconds($duration);

        $user = $this->resolveUser($username);
        if (!$user) {
            return $allowed;
        }

        /** @var \Concrete\Core\Entity\User\LoginAttemptRepository $repository */
        $repository = $this->entityManager->getRepository(LoginAttempt::class);
        $attempts = $repository->after($after, $user, true);

        return max(0, $allowed - $attempts);
    }
public function remainingAttempts($username)
    {
        $config = $this->config->get('concrete.user.deactivation.authentication_failure');

        $allowed = (int) array_get($config, 'amount', 0);
        $duration = (int) array_get($config, 'duration', 0);
        $after = Carbon::now('UTC')->subSeconds($duration);

        $user = $this->resolveUser($username);
        if (!$user) {
            return $allowed;
        }

        /** @var \Concrete\Core\Entity\User\LoginAttemptRepository $repository */
        $repository = $this->entityManager->getRepository(LoginAttempt::class);
        $attempts = $repository->after($after, $user, true);

        return max(0, $allowed - $attempts);
    }
public function remainingAttempts ( $ username ) { $ config = $ this -> config -> get ( 'concrete.user.deactivation.authentication_failure' ) ; $ allowed = ( int ) array_get ( $ config , 'amount' , 0 ) ; $ duration = ( int ) array_get ( $ config , 'duration' , 0 ) ; $ after = Carbon :: now ( 'UTC' ) -> subSeconds ( $ duration ) ; $ user = $ this -> resolveUser ( $ username ) ; if ( ! $ user ) { return $ allowed ; } /** @var \Concrete\Core\Entity\User\LoginAttemptRepository $repository */ $ repository = $ this -> entityManager -> getRepository ( LoginAttempt :: class ) ; $ attempts = $ repository -> after ( $ after , $ user , true ) ; return max ( 0 , $ allowed - $ attempts ) ; }
Determine the amount of attempts remaining for a username

@param $username
@return int
Determine the amount of attempts remaining for a username