Fase 2 (isla): selector de cuenta de juego en React/TSX, sin POST

El selector de cuenta de juego (bnet con varias) pasa a isla React y la selección
se hace vía GET (a petición), no POST:

- Nuevo endpoint GET /api/account/select/?account_id=<id> (account_select_api):
  idempotente y solo permite elegir cuentas ligadas a la bnet en sesión; fija la
  cuenta en sesión y devuelve {success, redirect}. 401 si no hay sesión bnet.
- select_account_view: se elimina el manejo de POST (queda solo la lógica GET:
  redirect si no hay bnet, autoseleccionar si hay una, render si hay varias).
- SelectAccount.tsx lee las cuentas embebidas con json_script y, al pulsar, hace
  fetch GET y redirige. Nueva entry 'select_account'.
- select_account.html: el <form> POST se sustituye por la isla + json_script.

Verificado: check OK, endpoint 401 sin sesión, /select-account/ redirige a login.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 20:50:37 +00:00
parent 8156befe4f
commit 45f48c2799
7 changed files with 117 additions and 24 deletions
+1 -10
View File
@@ -93,16 +93,7 @@ def select_account_view(request):
with connections['acore_auth'].cursor() as cursor:
game_accounts = bnet.get_game_accounts_for_bnet(cursor, bnet_id)
if request.method == 'POST':
try:
selected_id = int(request.POST.get('account_id', ''))
except (TypeError, ValueError):
selected_id = None
chosen = next((g for g in game_accounts if g['id'] == selected_id), None)
if chosen:
_set_game_account_session(request, chosen)
return redirect('my-account')
messages.error(request, 'Cuenta de juego no válida.')
# La selección la hace la isla React vía GET (/api/account/select/), sin POST.
# Autoseleccionar si solo hay una
if len(game_accounts) == 1: