as said by @stof, `app.user` does always exists, you should check `if app.user is not null`. ( https://github.com/symfony/symfony-docs/issues/2078#issuecomment-11777137 )