Block unverified users from marking themselves ready

GameDashboardService::toggleReady() now rejects the toggle if the
user's email isn't verified (mirrors the same gate UserChecker already
applies at login). The waiting-room checkbox is disabled client-side
with an explanatory alert and a link to resend the verification email,
and the controller adds a flash error as a server-side fallback if it
somehow gets submitted anyway.
This commit is contained in:
Frank
2026-07-11 23:25:50 +02:00
parent 886208c5c0
commit c28abef5b7
3 changed files with 17 additions and 2 deletions
+6 -1
View File
@@ -127,7 +127,12 @@ final class GameController extends AbstractController
$player = $playerRepository->findOneBy(['session' => $session, 'user' => $user]); $player = $playerRepository->findOneBy(['session' => $session, 'user' => $user]);
if ($request->isMethod('POST') && $request->request->has('toggle_ready')) { if ($request->isMethod('POST') && $request->request->has('toggle_ready')) {
$dashboardService->toggleReady($session, $user); if (!$user->isVerified()) {
$this->addFlash('error', 'You must verify your email address before you can mark yourself as ready.');
} else {
$dashboardService->toggleReady($session, $user);
}
return $this->redirectToRoute('game', ['session' => $session->getId()]); return $this->redirectToRoute('game', ['session' => $session->getId()]);
} }
@@ -290,6 +290,10 @@ final class GameDashboardService
return false; return false;
} }
if (!$user->isVerified()) {
return false;
}
$player = null; $player = null;
foreach ($session->getPlayers() as $p) { foreach ($session->getPlayers() as $p) {
if ($p->getUser() === $user) { if ($p->getUser() === $user) {
+7 -1
View File
@@ -56,9 +56,15 @@
<hr> <hr>
{% if not app.user.verified %}
<div class="alert alert-warning">
You must verify your email address before you can mark yourself as ready.
Check your inbox for the confirmation link, or <a href="{{ path('app_verify_resend_email') }}">request a new one</a>.
</div>
{% endif %}
<form method="post" class="mt-4"> <form method="post" class="mt-4">
<div class="form-check form-switch mb-3"> <div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="toggle_ready" name="toggle_ready" onchange="this.form.submit()" {{ isReady ? 'checked' : '' }}> <input class="form-check-input" type="checkbox" id="toggle_ready" name="toggle_ready" onchange="this.form.submit()" {{ isReady ? 'checked' : '' }} {{ not app.user.verified ? 'disabled' : '' }}>
<label class="form-check-label" for="toggle_ready"> <label class="form-check-label" for="toggle_ready">
<strong>I am ready to start!</strong> <strong>I am ready to start!</strong>
</label> </label>