locker = $locker; $this->requestStack = $requestStack; } protected function supports($attribute, $subject): bool { if (!in_array($attribute, $this->supported, true)) { return false; } return true; } protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { switch ($attribute) { case self::TRY_TOKEN: if (true === $this->locker->isLocked('invalid_token_global')) { return false; } $ip = $this->requestStack->getCurrentRequest()->getClientIp(); if (true === $this->locker->isLocked('invalid_token_by_ip', $ip)) { return false; } return true; case self::ASK_TOKEN: if (true === $this->locker->isLocked('ask_token_invalid_form_global')) { return false; } $ip = $this->requestStack->getCurrentRequest()->getClientIp(); if (true === $this->locker->isLocked('ask_token_invalid_form_by_ip', $ip)) { return false; } if ($subject instanceof User) { if (true === $this->locker->isLocked('ask_token_success_by_user', $subject)) { return false; } } return true; } return false; } }