Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,15 @@ public function unban(Request $request): RedirectResponse
'canceled' => true,
'canceled_at' => now(),
]);

// Lift the 48h minimum-vacation restriction that was imposed by the ban
// so the player can leave vacation mode immediately after being unbanned.
// The vacation_mode flag itself is left ON — the player chooses when to
// disable it; we only release the time-lock that the ban introduced.
if ($user->vacation_mode && $user->vacation_mode_until !== null && now()->lessThan($user->vacation_mode_until)) {
$user->vacation_mode_until = now();
$user->save();
}
}

return redirect()->route('admin.server-administration.index')
Expand Down
24 changes: 24 additions & 0 deletions tests/Feature/BanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@ public function testVacationModeRemainsAfterUnban(): void
$this->assertTrue((bool) $target->vacation_mode);
}

/**
* Test that unbanning lifts the 48h vacation lock so the player can leave vacation immediately.
*/
public function testUnbanLiftsVacationModeUntilRestriction(): void
{
$this->artisan('ogamex:admin:assign-role', ['username' => auth()->user()->username]);

$target = $this->createTrackedUser();
Ban::create(['user_id' => $target->id, 'reason' => 'Some violation', 'banned_until' => null, 'canceled' => false]);
$target->vacation_mode = true;
$target->vacation_mode_activated_at = now();
$target->vacation_mode_until = now()->addHours(48);
$target->save();

$this->post(route('admin.server-administration.unban'), [
'user_id' => $target->id,
]);

$target->refresh();
$this->assertFalse($target->isBanned());
$this->assertTrue((bool) $target->vacation_mode);
$this->assertTrue(now()->greaterThanOrEqualTo($target->vacation_mode_until));
}

/**
* Test that a banned user accessing an ingame page is logged out and redirected to login.
*/
Expand Down
Loading