samedi 26 décembre 2015

Auth::guest() returns false after going to another route or redirecting

I create a Laravel application with automatically generated authentication management via: 'php artisan make:auth' command, which created all (at least I think) needed.
Here is an excerpt of template app.blade.php, which illustrates header of page:

...
@if (Auth::guest())
     <li><a href="login">Login</a></li>
     <li><a href="register">Register</a></li>
@else
     <li class="dropdown">
     <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
     {{ Auth::user()->name }} <span class="caret"></span>
     </a>

     <ul class="dropdown-menu" role="menu">
           <li><a href="logout"><i class="fa fa-btn fa-sign-out"></i>Logout</a></li>
     </ul>
@endif
...

After I log in, I receive a navigate bar in header with option to logout and in my content, there is placed following code:

@extends('app')

@section('content')
<div class="container spark-screen">
<div class="row">
    <div class="col-md-10 col-md-offset-1">

                Hello in game! <br>
                @if(Auth::check())
                        {{ link_to_route('boot') }}
                @endif
    </div>
</div>
</div>
@endsection

after I log in

In other words, I have there a link to 'boot' page. Everything runs okey except that when I click on the link, my header stops to show option to logout, but options for login and register and it's wrong since I didn't logout yet. After clicking on the link
It seems to me, as if Laravel session was created only for 1 request. Do you have any idea what's wrong? This is not the only example when I met with this problem. After I redirect to another page, it makes same problem.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire