Files
hydra-sql/vendor/symfony/security-core/Exception/TooManyLoginAttemptsAuthenticationException.php

66 lines
1.5 KiB
PHP
Raw Normal View History

2022-05-03 08:54:45 +02:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* This exception is thrown if there where too many failed login attempts in
* this session.
*
* @author Wouter de Jong <wouter@wouterj.nl>
*/
class TooManyLoginAttemptsAuthenticationException extends AuthenticationException
{
private $threshold;
public function __construct(int $threshold = null)
{
$this->threshold = $threshold;
}
/**
* {@inheritdoc}
*/
public function getMessageData(): array
{
return [
'%minutes%' => $this->threshold,
'%count%' => (int) $this->threshold,
];
}
/**
* {@inheritdoc}
*/
public function getMessageKey(): string
{
return 'Too many failed login attempts, please try again '.($this->threshold ? 'in %minutes% minute'.($this->threshold > 1 ? 's' : '').'.' : 'later.');
}
/**
* {@inheritdoc}
*/
public function __serialize(): array
{
return [$this->threshold, parent::__serialize()];
}
/**
* {@inheritdoc}
*/
public function __unserialize(array $data): void
{
[$this->threshold, $parentData] = $data;
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
parent::__unserialize($parentData);
}
}