그냥 사는 이야기

Laravel 5.3 Sentinel - Logout & show content to logged users only 본문

Development/Web

Laravel 5.3 Sentinel - Logout & show content to logged users only

없다캐라 2020. 1. 21. 10:46
반응형

logout 구현

web.php
Route::post('/logout', 'LoginController@logout');
LoginController
public function logout()
{
    Sentinel::logout();
    return redirect('/login');
}
top.menu.php
<div class="header clearfix">
  <nav>
    <ul class="nav nav-pills pull-right">
      @if(Sentinel::check())
        <li role="presentation">
          <form action="/logout" method="POST" id="logout-form">
            {{ csrf_field() }}
            <a href="#" onclick="document.getElementById('logout-form').submit()">Logout</a>
          </form>
        </li>
      @else
        <li role="presentation"><a href="/login">Login</a></li>
        <li role="presentation"><a href="/register">Register</a></li>
      @endif
    </ul>
  </nav>
  <h3 class="text-muted">
    @if(Sentinel::check())
      Hello, {{ Sentinel::getUser()->first_name }}
    @else
      Authentication with Sentinel
    @endif
  </h3>
</div>

'Development > Web' 카테고리의 다른 글

Laravel 5.3 Sentinel - Restricting Access According to Roles  (0) 2020.01.21
Laravel 5.3 Sentinel - Roles  (0) 2020.01.21
Laravel 5.3 Sentinel - Menu  (0) 2020.01.21
Laravel 5.3 Sentinel - Login  (0) 2020.01.21
Laravel 5.3 Sentinel - Create User  (0) 2020.01.20
Comments