在我的symfony2应用程序中,我构建了一个异常监听器,它在发生异常时向我发送一封电子邮件(我过滤掉404并确保它不会因同一个异常每天多发一封电子邮件)。
然而,我一直得到一个"在SecurityContext中找不到一个令牌"当我认为机器人正在访问某些页面时(引用者是空的,页面位于防火墙后面,匿名= false)。 当我自己进入页面时,我被正确地重定向到登录页面,没有出现错误。
我知道如何解决这个问题?
在我的security.yml下面:
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
guest:
pattern: /(public/|$|genemu-captcha-refresh)
anonymous: true
context: main_auth
main:
pattern: ^/
anonymous: false
provider: main
context: main_auth
form_login:
login_path: fos_user_security_login
check_path: fos_user_security_check
logout:
path: fos_user_security_logout
target: /
以及带有跟踪的例外电子邮件:
Une erreur s'est produite sur le site.
Date 08/03/2015 à 00:49:33
Utilisateur anonyme
Url courante www.foodmeup.net/vote/flag/Post/le-lien-des-notifications-ne-marche-pas
Referer -
Url master www.foodmeup.net/vote/flag/Post/le-lien-des-notifications-ne-marche-pas
Url parent -
Code 0
Fichier /home/foodmeup.net/production/shared/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AccessListener.php
Ligne 53
Message A Token was not found in the SecurityContext.
Précédente erreur aucune
Trace as string #0 /home/foodmeup.net/production/releases/20150307222736/app/cache/prod/classes.php(2940): Symfony\Component\Security\Http\Firewall\AccessListener->handle(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent))
#1 [internal function]: Symfony\Component\Security\Http\Firewall->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher))
#2 /home/foodmeup.net/production/releases/20150307222736/app/cache/prod/classes.php(2193): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /home/foodmeup.net/production/releases/20150307222736/app/cache/prod/classes.php(2126): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent))
#4 /home/foodmeup.net/production/releases/20150307222736/app/cache/prod/classes.php(2287): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent))
#5 /home/foodmeup.net/production/releases/20150307222736/app/bootstrap.php.cache(3011): Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent))
#6 /home/foodmeup.net/production/releases/20150307222736/app/bootstrap.php.cache(2984): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#7 /home/foodmeup.net/production/releases/20150307222736/app/bootstrap.php.cache(3133): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 /home/foodmeup.net/production/releases/20150307222736/app/bootstrap.php.cache(2377): Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 /home/foodmeup.net/production/releases/20150307222736/web/app.php(27): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#10 {main}