Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AuthController extends Controller
public function index()
{
if (Auth::check()) {
return redirect()->route('admin.index');
return redirect()->route('me');
}

return Inertia::render('auth/Login');
Expand All @@ -29,7 +29,7 @@ public function index()
public function redirectToGoogle(Request $request)
{
if (Auth::check()) {
return redirect()->route('admin.index');
return redirect()->route('me');
}

if ($request->filled('redirect')) {
Expand Down
20 changes: 18 additions & 2 deletions tests/Feature/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@
use Illuminate\Support\Facades\Storage;
use Laravel\Socialite\Facades\Socialite;

test('login page is accessible', function () {
test('login page is accessible for guests', function () {
$response = $this->get('/login');

$response->assertStatus(200);
});

test('redirects to google for authentication', function () {
test('login page redirects authenticated users to /me', function () {
$user = User::factory()->create();

$response = $this->actingAs($user)->get('/login');

$response->assertRedirect(route('me'));
});

test('google auth redirects authenticated users to /me', function () {
$user = User::factory()->create();

$response = $this->actingAs($user)->get(route('auth.google'));

$response->assertRedirect(route('me'));
});

test('redirects to google for authentication for guests', function () {
$response = $this->get(route('auth.google'));

$response->assertRedirect();
Expand Down