Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
9b65966d27 | |||
633e30ae47 | |||
2f96c759ab | |||
2769e4791a | |||
5e434e1859 | |||
df6915eb5e | |||
b7685e63a1 | |||
15bee25e9c | |||
3a4e31473a | |||
fec0ebb2f1 |
@ -101,6 +101,7 @@ number of lines depends on the size of the image). (default=null)
|
|||||||
* **background_images**: Sets custom user defined images as the captcha background (1 image is selected randomly). It is recommended to turn off all the effects on the image (ignore_all_effects). The full paths to the images must be passed.
|
* **background_images**: Sets custom user defined images as the captcha background (1 image is selected randomly). It is recommended to turn off all the effects on the image (ignore_all_effects). The full paths to the images must be passed.
|
||||||
* **interpolation**: enable or disable the interpolation on the captcha
|
* **interpolation**: enable or disable the interpolation on the captcha
|
||||||
* **ignore_all_effects**: Recommended to use when setting background images, will disable all image effects.
|
* **ignore_all_effects**: Recommended to use when setting background images, will disable all image effects.
|
||||||
|
* **session_key**, if you want to host multiple CAPTCHA on the same page, you might have different session keys to ensure proper storage of the clear phrase for those different forms
|
||||||
|
|
||||||
Example :
|
Example :
|
||||||
|
|
||||||
@ -131,13 +132,15 @@ The messages are using the translator, you can either change the `invalid_messag
|
|||||||
|
|
||||||
As URL
|
As URL
|
||||||
============
|
============
|
||||||
To use a URL to generate a captcha image, you must add the bundle's routing configuration to your app/routing.yml file:
|
To use a URL to generate a captcha image, you must add the bundle's routing configuration to your `config/routes.yaml` file:
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
gregwar_captcha_routing:
|
gregwar_captcha_routing:
|
||||||
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
||||||
```
|
```
|
||||||
|
|
||||||
This will use the bundle's route of "/generate-captcha/{key}" to handle the generation. If this route conflicts with an application route, you can prefix the bundle's routes when you import:
|
This will use the bundle's route of `/generate-captcha/{key}` to handle the generation. If this route conflicts with an application route, you can prefix the bundle's routes when you import:
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
gregwar_captcha_routing:
|
gregwar_captcha_routing:
|
||||||
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
resource: "@GregwarCaptchaBundle/Resources/config/routing/routing.yml"
|
||||||
|
@ -17,6 +17,7 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@gregwar_captcha.generator'
|
- '@gregwar_captcha.generator'
|
||||||
- '%gregwar_captcha.config%'
|
- '%gregwar_captcha.config%'
|
||||||
|
autowire: true
|
||||||
|
|
||||||
# captcha.type:
|
# captcha.type:
|
||||||
gregwar_captcha.type:
|
gregwar_captcha.type:
|
||||||
|
@ -62,7 +62,8 @@ class CaptchaType extends AbstractType
|
|||||||
sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']),
|
sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']),
|
||||||
$options['invalid_message'],
|
$options['invalid_message'],
|
||||||
$options['bypass_code'],
|
$options['bypass_code'],
|
||||||
$options['humanity']
|
$options['humanity'],
|
||||||
|
$options['request']
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::POST_SUBMIT, array($validator, 'validate'));
|
$builder->addEventListener(FormEvents::POST_SUBMIT, array($validator, 'validate'));
|
||||||
@ -121,6 +122,7 @@ class CaptchaType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$this->options['mapped'] = false;
|
$this->options['mapped'] = false;
|
||||||
|
$this->options['request'] = null;
|
||||||
$resolver->setDefaults($this->options);
|
$resolver->setDefaults($this->options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Captcha validator.
|
* Captcha validator.
|
||||||
@ -54,13 +55,21 @@ class CaptchaValidator
|
|||||||
*/
|
*/
|
||||||
private $translator;
|
private $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request
|
||||||
|
*
|
||||||
|
* @var Request
|
||||||
|
*/
|
||||||
|
private $req;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
SessionInterface $session,
|
SessionInterface $session,
|
||||||
string $key,
|
string $key,
|
||||||
string $invalidMessage,
|
string $invalidMessage,
|
||||||
?string $bypassCode,
|
?string $bypassCode,
|
||||||
int $humanity
|
int $humanity,
|
||||||
|
?Request $req
|
||||||
) {
|
) {
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
@ -94,12 +103,13 @@ class CaptchaValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null == $this->req || 1 < $this->req->get('flow_registration_step')) {
|
||||||
$this->session->remove($this->key);
|
$this->session->remove($this->key);
|
||||||
|
|
||||||
if ($this->session->has($this->key.'_fingerprint')) {
|
if ($this->session->has($this->key.'_fingerprint')) {
|
||||||
$this->session->remove($this->key.'_fingerprint');
|
$this->session->remove($this->key.'_fingerprint');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the expected CAPTCHA code.
|
* Retrieve the expected CAPTCHA code.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "gregwar/captcha-bundle",
|
"name": "cadoles/captcha",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"description": "Captcha bundle",
|
"description": "Captcha bundle",
|
||||||
"keywords": ["symfony2", "symfony", "captcha", "bot", "visual", "code", "security", "spam"],
|
"keywords": ["symfony2", "symfony", "captcha", "bot", "visual", "code", "security", "spam"],
|
||||||
"homepage": "https://github.com/Gregwar/CaptchaBundle",
|
"homepage": "https://github.com/Cadoles/CaptchaBundle",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@ -17,9 +17,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": ">=7.1.3",
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
"gregwar/captcha": "~1.1",
|
"gregwar/captcha": "^1.1.9",
|
||||||
"symfony/form": "~4.0|~5.0",
|
"symfony/form": "~4.0|~5.0",
|
||||||
"symfony/framework-bundle": "~4.0|~5.0",
|
"symfony/framework-bundle": "~4.0|~5.0",
|
||||||
"symfony/translation": "~4.0|^5.0",
|
"symfony/translation": "~4.0|^5.0",
|
||||||
|
Reference in New Issue
Block a user