簡體   English   中英

symfony Twig_Error_Runtime,無身份驗證令牌

[英]symfony Twig_Error_Runtime, no authentication token

我嘗試解決錯誤幾天都沒有成功。 我真的不知道在哪里搜索了。

我的錯誤是:

[2015-09-27 17:59:15] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /css/"" at /home/clickandi/www/app/cache/prod/classes.php line 1985 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /css/\" at /home/clickandi/www/app/cache/prod/classes.php:1985, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/clickandi/www/app/cache/prod/appProdUrlMatcher.php:1011)"} []
[2015-09-27 17:59:17] request.ERROR: Exception thrown when handling an exception (Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("The security context contains no authentication token. One possible reason may be that there is no firewall configured for this URL.") in "::navbar.html.twig" at line 72.) {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /css/\" at /home/clickandi/www/app/cache/prod/classes.php:1985, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/clickandi/www/app/cache/prod/appProdUrlMatcher.php:1011)"} []

我在導航欄第72行上擁有的唯一東西是:{%is_granted('ROLE_USER')%}

導航欄位於每個頁面上,可以使用或不使用帳戶訪問頁面。

在網站上,有時我的空白頁上只有付款表格。 我還不知道是否是因為此錯誤,當我清除緩存時出現錯誤,主頁再次恢復正常。

請我真的需要幫助,因為我無法提供此錯誤的網站

編輯:

沒有修復錯誤,現在我得到:

[2015-09-28 05:13:44] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /newpassword.php"" at /home/clickandi/www/app/cache/prod/classes.php line 1985 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /newpassword.php\" at /home/clickandi/www/app/cache/prod/classes.php:1985, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/clickandi/www/app/cache/prod/appProdUrlMatcher.php:1011)"} []
[2015-09-28 05:13:47] request.ERROR: Exception thrown when handling an exception (Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("The security context contains no authentication token. One possible reason may be that there is no firewall configured for this URL.") in "::navbar.html.twig" at line 72.) {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /newpassword.php\" at /home/clickandi/www/app/cache/prod/classes.php:1985, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/clickandi/www/app/cache/prod/appProdUrlMatcher.php:1011)"} []

非常奇怪,因為我的項目中沒有任何newpassword.php

在第72行,我有:{%如果app.user和is_granted('ROLE_USER')%}

編輯2:

這是我的導航欄模板:

<div class="isConnexion">
</div>

<div class="forConnexion">
  <div class="closeForConnexion">
    <img src="{{asset('img/crossClose.png')}}" alt="">
  </div>
  <h2>CONNEXION</h2>
  <div class="container-modal">
  </div>
  <div class="mdpOublie">
    <p><a href="{{ path('fos_user_resetting_request') }}">Mot de passe oublié ?</a></p>
  </div>
  <!-- <div class="facebookLogin">
    <h2>Se connecter avec facebook</h2>
  </div> -->
  <a href="{{ path('user_register') }}"><div class="inscrivezVous">
    <h2>INSCRIVEZ VOUS</h2>
  </div></a>
</div>

<div class="forParrainage">

  <h2>Saisissez votre code</h2>
  <p>Notre système de parrainage unique vous permet d’offrir gratuitement un verre à un ami. Pour cela il vous suffit de renseigner le code que le bar partenaire de click and cheers vous a donné avec votre addition.</p>

  <div class="champsParrainagePopUPHeader">
    <p>Votre code</p>

    <input type="text" class="codeValue" placeholder="Ex: 435e5d" maxlength="6">
  </div>

  <button class="ticketVerreValidate">Valider</button>

</div>

<div class="popupsponsorship completionAdresse">
  <h2>On lui offre quand ?</h2>
  <div id="datepicker"></div>
  <input type="text" id="datepickerInput" hidden>
  <input type="text" id="codeInput" hidden>
</div>

<div class="emailsponsorship" style="display:none;">
  <h2>Qui sera l'élu(e) ?</h2>
  <p>Notre système de parrainage unique vous permet d'offrir un verre gratuitement à un ami.</p>
  <p>Il ne vous reste donc plus qu'à choisir l'ami en question.</p> 
  <br/>
  <p>Invitez le par email</p>
  <input id="mailToSend" type="email" placeholder="Tapez ici son adresse e-mail">
  <!--<br/>
  <br/>
  <p>Invitez le par facebook messenger</p>
  <input type="email" placeholder="Tapez ici son Prénom et Nom">-->
  <br/>
  <button id="senddrink">Valider</button>
</div>

<nav class="menuNav">
    <button class="hidden-sm hidden-md hidden-lg menu__handle">
        <span>Menu</span>
    </button>
    <div class="contentLogo">
        <a href="{{ path('home') }}">
            <img src="{{asset('img/LogoClickandcheers.svg')}}" alt="Click and Cheers">
        </a>
    </div>
    <div class="menuMob">


        <div class="administration">
            {% if app.user and is_granted('ROLE_USER') %}
                <div class="profileUserNav">
                  <img class="hidden-sm hidden-md hidden-lg" src="{{asset('img/imgProfilBasic.png')}}">
                  {% if is_granted('ROLE_BARMAN') and not is_granted('ROLE_BIGBOSS') %}
                    <p>Bonjour <span class="nameInHeader">{{ app.user.getUsername()}}</span> </p>
                  {% else %}
                    <p>Bonjour <span class="nameInHeader">{{ app.user.firstname}}</span> </p>
                  {% endif %}
                </div>
                <div class="row">
                  <div class="col-xs-12 hidden-sm hidden-md hidden-lg">
                    <div class="col-xs-4 hidden-sm hidden-md hidden-lg">
                      <img src="{{asset('img/pictoHeader/reservation.svg')}}">
                    </div>
                  </div>
                </div>
                <div class="clear"></div>
                <ul>
                    {% if app.user and is_granted('ROLE_BIGBOSS') or is_granted('ROLE_BARMAN') %}
                        <li>
                            {% render url('navigation') %}
                            <a href="{{ path('barman_register') }}"><p>Ajouter un barman</p></a>
                            {% if is_granted('ROLE_BIGBOSS') %}
                              <a href="{{ path('bar_new') }}"><p>Créer un bar</p></a>
                              <a href="{{ path('bars_list') }}"><p>Mes bars</p></a>
                            {% endif %}
                        </li>
                        <li class="navToggleBtn logout"><a href="#" class="displayMore"><p>Afficher plus</p></a></li>
                        <li class="navToggle navLine"><div class="lisere"></div></li>
                        <li class="navToggle"><a class="mesReservation" href="{{ path('fos_user_profile_show') }}"><p>Mes réservations</p></a></li>
                        <li class="navToggle"><a class="mesParrainage" href="{{ path('fos_user_profile_show') }}"><p>Mes parrainages</p></a></li>
                        <li class="navToggle"><a class="monCompte" href="{{ path('fos_user_profile_show') }}"><p>Mon compte</p></a></li>
                        <li class="navToggle hidden"><a href="{{ path('fos_user_profile_show') }}"><p>Mes points</p></a></li>
                    {% else %}
                        <li><a class="mesReservation" href="{{ path('fos_user_profile_show') }}"><p>Mes réservations</p></a></li>
                        <li><a class="mesParrainage" href="{{ path('fos_user_profile_show') }}"><p>Mes parrainages</p></a></li>
                        <li><a class="monCompte" href="{{ path('fos_user_profile_show') }}"><p>Mon compte</p></a></li>
                        <li class="navToggle hidden"><a href="{{ path('fos_user_profile_show') }}"><p>Mes points</p></a></li>
                    {% endif %}
                    <li class="logout"><a href="{{ path('fos_user_security_logout') }}"><p>Déconnexion</p></a></li>
                </ul>
            {% else %}
                <div class="connexionInscription">
                    <p class="animConnexion">Connexion</p>
                    <p><a href="{{ path('user_register') }}">Inscription</a></p>
                </div>
            {% endif %}
        </div>
        <div class="contentNav">
            <div class="row">
                <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-8 col-md-offset-2">
                    <div class="col-xs-12 hidden-sm hidden-md hidden-lg noPadding">
                    {% if app.user and is_granted('ROLE_USER') %}
                        {% if is_granted('ROLE_BARMAN') and not is_granted('ROLE_BIGBOSS') %}
                          <p>Bonjour <span class="nameInHeader">{{ app.user.getUsername()}}</span> </p>
                        {% else %}
                          <p>Bonjour <span class="nameInHeader">{{ app.user.firstname}}</span> </p>
                        {% endif %}
                      {% else %}
                        <div class="col-xs-12 hidden-sm hidden-md hidden-lg noPadding">
                            <p class="leftMobile animConnexion">Connexion</p>
                            <p class="leftMobile"><a href="{{ path('user_register') }}">Inscription</a></p>
                        </div>
                        <div class="clear"></div>
                        <div class="separationHeader"></div>
                     {% endif %}
                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-4 noPadding">
                        <p class="leftMobile"><a class="trouverBar" href="{{ path('bars') }}">Trouver un bar</a></p>
                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-4 noPadding">
                        <p class="leftMobile"><a class="hasard" href="{{ path('randomBar') }}">Au hasard</a></p>
                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-4 noPadding">
                        <p class="leftMobile"><a class="parrainage" href="#">Parrainage</a></p>
                    </div>

                    {% if app.user and is_granted('ROLE_USER') %}
                    <div class="clear"></div>
                    <div class="separationHeader"></div>
                    {% if is_granted('ROLE_BIGBOSS') or is_granted('ROLE_BARMAN') %}

                        <div class="col-xs-12 hidden-sm hidden-md hidden-lg noPadding">
                          <p class="leftMobile"><a href="{{ path('barman_register') }}">Ajouter un barman</a></p>

                        {% if is_granted('ROLE_BIGBOSS') %}

                            <p class="leftMobile"><a href="{{ path('bar_new') }}">Créer un bar</a></p>
                            <p class="leftMobile"><a href="{{ path('bars_list') }}">Mes bars</a></p>

                        {% endif %}
                        </div>
                        <div class="clear"></div>
                        <div class="separationHeader"></div>
                      {% endif %}
                      <div class="col-xs-12 hidden-sm hidden-md hidden-lg noPadding">

                        <p class="leftMobile mesReservation"><a href="{{ path('fos_user_profile_show') }}">Mes réservations</a></p>

                        <p class="leftMobile mesParrainage"><a href="{{ path('fos_user_profile_show') }}">Mes parrainages</a></p>

                        <p class="leftMobile monCompte"><a href="{{ path('fos_user_profile_show') }}">Mon compte</a></p>

                        <p class="leftMobile"><a href="{{ path('fos_user_profile_show') }}">Mes points</a></p>

                        <p class="logout"><a href="{{ path('fos_user_security_logout') }}">Déconnexion</a></p>
                      </div>

                      {% endif %}
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</nav>

<script type="text/javascript">
function souris(event)
{
  var x = event.clientX;
  var y = event.clientY;
  //alert('Vous avez cliqué au point de coordonnés: ' + x + ', ' + y );
}</script>

您應該閱讀Symfony文檔中的在錯誤模板使用安全功能時避免例外 ,內容如下:

設計自定義錯誤頁面時常見的陷阱之一是在錯誤模板中使用is_granted()函數。此問題的原因是路由在安全之前完成。 如果發生404錯誤,則不會加載安全層,因此is_granted()函數是未定義的。

這就是你發生的事。 該問題的解決方案在文檔中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM