Cartalyst\Sentinel\Checkpoints\ThrottleCheckpoint::fail PHP Метод

fail() публичный Метод

{@inheritDoc}
public fail ( Cartalyst\Sentinel\Users\UserInterface $user = null )
$user Cartalyst\Sentinel\Users\UserInterface
    public function fail(UserInterface $user = null)
    {
        // We'll check throttling firstly from any previous attempts. This
        // will throw the required exceptions if the user has already
        // tried to login too many times.
        $this->checkThrottling('login', $user);
        // Now we've checked previous attempts, we'll log this latest attempt.
        // It'll be picked up the next time if the user tries again.
        $this->throttle->log($this->ipAddress, $user);
    }

Usage Example

Пример #1
0
 public function testGetThrottlingExceptionAttributes()
 {
     $checkpoint = new ThrottleCheckpoint($throttle = m::mock('Cartalyst\\Sentinel\\Throttling\\IlluminateThrottleRepository'), '127.0.0.1');
     $throttle->shouldReceive('globalDelay')->once();
     $throttle->shouldReceive('ipDelay')->once()->andReturn(0);
     $throttle->shouldReceive('userDelay')->once()->andReturn(10);
     try {
         $checkpoint->fail(m::mock('Cartalyst\\Sentinel\\Users\\EloquentUser'));
     } catch (ThrottlingException $e) {
         $this->assertEquals(10, $e->getDelay());
         $this->assertEquals('user', $e->getType());
         $this->assertEquals(Carbon::now()->addSeconds(10), $e->getFree());
     }
 }