src/Webiny/Login/Login.php
public function rateLimitReached()
    {
        if ($this->isIpWhitelisted()) {
            return false; // we cannot block whitelisted IPs
        }

        if ($this->isIpBlacklisted()) {
            return true;
        }

        $rateLimit = $this->config->get('BlockThreshold', 0);
        if ($rateLimit < 1) {
            return false; // rate limit not used
        }

        // get the last record that's on the end of the rate limit window
        $rc = LoginRateControlEntity::find(['ip' => $this->ip], ['-timestamp'], 1, $rateLimit);
        if (!$rc) {
            return false;
        }

        $blockTtl = $this->config->get('BlockTimelimit', 1) * 60; // defined in minutes, cast to seconds
        if ((time() - $blockTtl) > 60) {
            return false;
        }

        return true;
    }
public function rateLimitReached()
    {
        if ($this->isIpWhitelisted()) {
            return false; // we cannot block whitelisted IPs
        }

        if ($this->isIpBlacklisted()) {
            return true;
        }

        $rateLimit = $this->config->get('BlockThreshold', 0);
        if ($rateLimit < 1) {
            return false; // rate limit not used
        }

        // get the last record that's on the end of the rate limit window
        $rc = LoginRateControlEntity::find(['ip' => $this->ip], ['-timestamp'], 1, $rateLimit);
        if (!$rc) {
            return false;
        }

        $blockTtl = $this->config->get('BlockTimelimit', 1) * 60; // defined in minutes, cast to seconds
        if ((time() - $blockTtl) > 60) {
            return false;
        }

        return true;
    }
public function rateLimitReached ( ) { if ( $ this -> isIpWhitelisted ( ) ) { return false ; // we cannot block whitelisted IPs } if ( $ this -> isIpBlacklisted ( ) ) { return true ; } $ rateLimit = $ this -> config -> get ( 'BlockThreshold' , 0 ) ; if ( $ rateLimit < 1 ) { return false ; // rate limit not used } // get the last record that's on the end of the rate limit window $ rc = LoginRateControlEntity :: find ( [ 'ip' => $ this -> ip ] , [ '-timestamp' ] , 1 , $ rateLimit ) ; if ( ! $ rc ) { return false ; } $ blockTtl = $ this -> config -> get ( 'BlockTimelimit' , 1 ) * 60 ; // defined in minutes, cast to seconds if ( ( time ( ) - $ blockTtl ) > 60 ) { return false ; } return true ; }
Check if current IP should be blocked from login page
Check if current IP should be blocked from login page