mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 18:01:37 +00:00
fix logout issue #31
This commit is contained in:
parent
ee7e880452
commit
229696e435
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class DeleteServer
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function delete(Server $server, array $input): void
|
||||
{
|
||||
$this->validateDelete($input);
|
||||
|
||||
DB::transaction(function () use ($server) {
|
||||
$server->cleanDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validateDelete(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'confirm' => 'required|in:delete',
|
||||
])->validateWithBag('deleteServer');
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class DeleteSite
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(Site $site, array $input): void
|
||||
{
|
||||
$this->validateDelete($input);
|
||||
|
||||
$site->update(['status' => 'deleting']);
|
||||
|
||||
$site->remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validateDelete(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'confirm' => 'required|in:delete',
|
||||
])->validateWithBag('deleteSite');
|
||||
}
|
||||
}
|
@ -5,10 +5,10 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
@ -43,6 +43,6 @@ public function destroy(Request $request): RedirectResponse
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
return redirect()->route('login');
|
||||
}
|
||||
}
|
||||
|
@ -148,9 +148,10 @@
|
||||
<x-slot name="content">
|
||||
<x-dropdown-link :href="route('profile')">Profile</x-dropdown-link>
|
||||
<div class="border-t border-gray-100 dark:border-gray-700"></div>
|
||||
<form>
|
||||
<x-dropdown-link as="button">
|
||||
Log Out
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
<x-dropdown-link :href="route('logout')" onclick="event.preventDefault(); this.closest('form').submit();">
|
||||
{{ __('Log Out') }}
|
||||
</x-dropdown-link>
|
||||
</form>
|
||||
</x-slot>
|
||||
|
29
tests/Feature/Http/Auth/LogoutTest.php
Normal file
29
tests/Feature/Http/Auth/LogoutTest.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Http\Auth;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LogoutTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_logout(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('logout'))->assertRedirect(route('login'));
|
||||
|
||||
$this->assertFalse(auth()->check());
|
||||
}
|
||||
|
||||
public function test_user_still_logged_in(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->get(route('login'))->assertRedirect(route('servers'));
|
||||
|
||||
$this->assertTrue(auth()->check());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user