Fixing session key, removing valid_keys which was painful to transport

the whitelist in the session (see #36)
This commit is contained in:
Gregwar
2012-12-04 11:33:54 +01:00
parent 39532390e1
commit 31d080a9b7
7 changed files with 42 additions and 12 deletions

View File

@ -24,7 +24,18 @@ class CaptchaController extends Controller
public function generateCaptchaAction(Request $request, $key)
{
$options = $this->container->getParameter('gregwar_captcha.config');
if (!$options['as_url'] || !in_array($key, $options['valid_keys'])) {
$session = $this->get('session');
$whitelistKey = $options['whitelist_key'];
$isOk = false;
if ($options['as_url'] && $session->has($whitelistKey)) {
$keys = $session->get($whitelistKey);
if (is_array($keys) && in_array($key, $keys)) {
$isOk = true;
}
}
if (!$isOk) {
return $this->createNotFoundException('Unable to generate a captcha via a URL without the proper configuration.');
}