bug(copi): next_round and toggle_continue_vote can be triggered on unstarted or finished games

Abierto
#3,762 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@Abhrant-Singh ya está trabajando en esto.

Desde el 9/11/2026.

  • #3769 de @Abhrant-Singh — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

Describe the bug

In copi.owasp.org/lib/copi_web/live/player_live/show.ex, while toggle_vote verifies that a game is active before accepting votes (via PR #3662), next_round and toggle_continue_vote do not check game.started_at or game.finished_at.

As a result:

  • On unstarted games: A player in the lobby can trigger next_round. Because cards haven't been dealt yet, last_round? evaluates to true, which immediately sets finished_at and ends the game session before the host can start it.
  • On finished games: Players can continue calling next_round and toggle_continue_vote, modifying database state and advancing rounds_played on a completed game.
Code Reference

In copi.owasp.org/lib/copi_web/live/player_live/show.ex:

  • handle_event("next_round", ...) (lines 122–152)
  • handle_event("toggle_continue_vote", ...) (lines 155–192)

Neither handler checks is_nil(game.started_at) or not is_nil(game.finished_at), unlike handle_toggle_vote in the same file.

Expected Behavior

Both events should require the game to be active (not is_nil(game.started_at) and is_nil(game.finished_at)), matching Copi.Cornucopia.Game.active?/1 and rejecting calls on unstarted or finished games with a flash notice.

Proposed Solution

Add the existing lifecycle guard checks to both handlers in player_live/show.ex and add LiveView regression tests in show_test.exs.

Lenguaje dominante
Python
Estrellas
158
Forks
110
Merge medio
1 d 11 h
PR fusionados (30 d)
115

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de OWASP/cornucopia

Todos los issues de OWASP/cornucopia

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.