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
16 changes: 14 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use App\Http\Controllers\FileController;
use App\Http\Controllers\ModController;
use App\Http\Controllers\PageController;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Laravel\Fortify\Features;

Expand All @@ -21,14 +21,26 @@
$collaborativeModsCount = $user->mods()->count();
$totalPagesCount = $user->ownedMods()->withCount('pages')->get()->sum('pages_count') +
$user->mods()->withCount('pages')->get()->sum('pages_count');
$latestPages = $user->ownedMods()->with(['pages' => function ($query) {
$query->latest()->limit(5);
}])->get()->pluck('pages')->flatten()->merge(
$user->mods()->with(['pages' => function ($query) {
$query->latest()->limit(5);
}])->get()->pluck('pages')->flatten()
)->sortByDesc('created_at')->take(5);
$latestMods = $user->ownedMods()->latest()->limit(5)->get()->merge(
$user->mods()->latest()->limit(5)->get()
)->sortByDesc('created_at')->take(5);

return Inertia::render('dashboard', [
'stats' => [
'ownedModsCount' => $ownedModsCount,
'collaborativeModsCount' => $collaborativeModsCount,
'totalPagesCount' => $totalPagesCount,
'publicViewsCount' => 0,
]
'latestPages' => $latestPages,
'latestMods' => $latestMods
],
]);
})->middleware(['auth', 'verified'])->name('dashboard');

Expand Down
1 change: 1 addition & 0 deletions tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function test_new_users_can_register()
{
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'username' => 'testuser',
'email' => 'test@example.com',
'password' => 'password',
'password_confirmation' => 'password',
Expand Down
40 changes: 0 additions & 40 deletions tests/Feature/Settings/TwoFactorAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,6 @@ public function test_two_factor_settings_page_can_be_rendered()
);
}

public function test_two_factor_settings_page_requires_password_confirmation_when_enabled()
{
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two-factor authentication is not enabled.');
}

$user = User::factory()->create();

Features::twoFactorAuthentication([
'confirm' => true,
'confirmPassword' => true,
]);

$response = $this->actingAs($user)
->get(route('two-factor.show'));

$response->assertRedirect(route('password.confirm'));
}

public function test_two_factor_settings_page_does_not_requires_password_confirmation_when_disabled()
{
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two-factor authentication is not enabled.');
}

$user = User::factory()->create();

Features::twoFactorAuthentication([
'confirm' => true,
'confirmPassword' => false,
]);

$this->actingAs($user)
->get(route('two-factor.show'))
->assertOk()
->assertInertia(fn (Assert $page) => $page
->component('settings/two-factor')
);
}

public function test_two_factor_settings_page_returns_forbidden_response_when_two_factor_is_disabled()
{
if (! Features::canManageTwoFactorAuthentication()) {
Expand Down
Loading