mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
(add basic logout test and endpoint)
This commit is contained in:
@@ -23,4 +23,10 @@ class LoginController extends Controller
|
||||
|
||||
return redirect('/backstage/concerts/new');
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<img src="/img/logo.svg" alt="TicketBeast" style="height: 2.5rem;">
|
||||
</div>
|
||||
<div>
|
||||
<form class="inline-block" action="#" method="POST">
|
||||
<form class="inline-block" action="{{ route('auth.logout') }}" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<button type="submit" class="link link-light">Log out</button>
|
||||
</form>
|
||||
|
||||
@@ -15,7 +15,8 @@ Route::get('/concerts/{id}', 'ConcertsController@show');
|
||||
Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store');
|
||||
Route::get('/orders/{confirmationNumber}', 'OrdersController@show');
|
||||
|
||||
Route::get('/login', 'Auth\LoginController@showLoginForm');
|
||||
Route::post('/login', 'Auth\LoginController@login');
|
||||
Route::get('/login', 'Auth\LoginController@showLoginForm')->name('auth.show-login');
|
||||
Route::post('/login', 'Auth\LoginController@login')->name('auth.login');
|
||||
Route::post('/logout', 'Auth\LoginController@logout')->name('auth.logout');
|
||||
|
||||
Route::get('/backstage/concerts/new', 'Backstage\ConcertsController@create');
|
||||
|
||||
@@ -69,4 +69,15 @@ class PromoterLoginTest extends TestCase
|
||||
$this->assertFalse(session()->hasOldInput('password'));
|
||||
$this->assertFalse(Auth::check());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function logging_out_the_current_user()
|
||||
{
|
||||
Auth::login(factory(User::class)->create());
|
||||
|
||||
$response = $this->post('/logout');
|
||||
|
||||
$response->assertRedirect('/login');
|
||||
$this->assertFalse(Auth::check());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user