Repository navigation
feat(backend): let an account be edited instead of deleted and recreated (#100) - #105
Merged
Merged
Conversation
…ted (#100) Closes #100. UserController had index(), store() and destroy() and nothing in between. Any mistake in a registration could only be fixed by deleting the account -- which cascades to its runs, scores, tasks and logs, with no undo. Name, email, username, user_type, site, is_enabled and icpc_id were all uncorrectable once saved. The last one was concrete: #92 added icpc_id to the create form, so an account that already existed had no way to receive one, and that is the exact column contest:icpc-report needs filled on every team. The command lists who is missing it precisely so an organiser can fill them in, and there was nowhere to do it. Editing keeps the row, so everything pointing at it survives. A blank password means "leave it alone" rather than "set an empty password", and the contest follows the chosen site exactly as it does on create. Two guards, on both edit and delete, because there is no second screen to undo either from: - You cannot disable or delete your own account. - The last admin cannot be demoted or deleted. destroy() had no guard at all before this: deleting the only admin was one confirm dialog away. Also makes icpc_id fillable on the User model. It has existed since 2025_11_25_000007 and was never in $fillable, so an Eloquent update dropped it silently -- the create path writes through the query builder, which is why #92 worked and this did not until now. Thirteen tests, including the two mistakes that would otherwise pass review: saving a user without changing their username must not collide with their own record, and another account's username must still be refused. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY
This was referenced Sep 13, 2026
matbrgz
added a commit
that referenced
this pull request
Sep 13, 2026
…ads (#99) (#111) Closes #99. /backend/teams sat in the main admin sidebar and read `DB::table('teams')`, the Helium table from 2017 -- team_id, teamName, score. The contest's actual teams are rows in `users` with user_type='team', which is what SubmitController, Leaderboard, Score, BocaWebcastZipBuilder and the ICPC report all use. After #107 removed the other two readers, the audit was unambiguous: `exercises` has no reader or writer left anywhere, and `teams` had exactly one consumer -- this screen, which read, wrote and deleted its own table while nothing else ever looked at what it wrote. Not a screen that had fallen out of date; a closed loop that was never connected to anything. Both reference implementations model this the same way, and neither the way this screen did: BOCA has one usertable and one admin/user.php; a team is a user with type='team'. There is no teams table and no teams screen. CD-MOJ's source of truth is contests/<id>/users/<login>/, one directory per account. It does have a "Times" screen, but read what it is: "Identidade de cada conta no placar: nome do time, país/bandeira, sede, universidade, brasão e foto" -- presentation metadata hanging off accounts, with the roster in a separate "Inscrições" screen. So the menu slot is worth having eventually; what occupied it was not it. #105 gave account editing a real home in /backend/users, and /site/teams already lists a site's real teams. The four legacy tables (teams, exercises, exercise_team, team_user) are deliberately left in place. Dropping them is irreversible and I cannot verify from here whether anything outside this repository reads that database -- an old report, an operations script. The screen is the part that was actively misleading, and removing it changes no data. Claude-Session: https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fecha a #100.
O
UserControllertinhaindex(),store()edestroy()e nada entre eles. Qualquer erro num cadastro só se corrigia apagando a conta — o que arrasta runs, scores, tarefas e logs porcascadeOnDelete, sem desfazer. Nome, e-mail, usuário, tipo, sede,is_enabledeicpc_ideram todos incorrigíveis depois de salvos.O último era concreto: a #92 adicionou o
icpc_idao formulário de criação, então conta que já existia não tinha como receber o dela — e é exatamente a coluna que ocontest:icpc-reportprecisa preenchida em todas as equipes. O comando lista quem está sem justamente para o organizador preencher, e não havia onde.O que muda
Editar mantém a linha, então tudo que aponta para ela sobrevive. Senha em branco significa "deixa como está", não "põe senha vazia". A competição acompanha a sede escolhida, igual na criação.
Duas guardas, no editar e no excluir
Porque não existe uma segunda tela para desfazer nenhum dos dois:
O
destroy()não tinha guarda nenhuma antes disto: apagar o único administrador estava a um diálogo de confirmação de distância.Um bug que apareceu no caminho
icpc_idnunca esteve no$fillabledoUser. Existe desde2025_11_25_000007e umupdate()do Eloquent o descartava em silêncio. O caminho de criação escreve pelo query builder, que é por isso que a #92 funcionou e a edição não funcionaria.Testes
13, incluindo os dois erros que passariam por uma revisão desatenta: salvar um usuário sem mudar o nome de usuário não pode colidir com o próprio registro, e o nome de usuário de outra conta continua recusado.
Suíte: 788 verdes.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY