Implementa la recuperación de cuenta (contraseña / cuentas / activación) + islas

recover_account_view era un stub que solo renderizaba (los formularios no tenían
backend y el HTML arrastraba un reCAPTCHA de otro dominio). Ahora es funcional:

Backend:
- Modelo PasswordReset (token+email+expiración 1h) + migración 0014.
- recover_account_view maneja POST JSON con 3 tipos, todo por email (bnet), con
  respuestas genéricas anti-enumeración:
  * password: crea token y envía enlace de reset (emails/password_reset.html).
  * accountname: envía las cuentas de juego ligadas (emails/account_names.html).
  * activation: reenvía el enlace de activación pendiente (emails/activation.html).
- reset_password_view: GET valida el token (isla), POST re-deriva el verifier
  SRP6 v2 de la cuenta bnet (bnet.bnet_make_registration) y lo actualiza; marca el
  token usado. Ruta 'reset-password'.
- Resiliente si la BD de cuentas (AzerothCore) no está disponible: mensaje limpio,
  nunca 500.

Frontend (islas Vite): RecoverForm.tsx (selector de tipo + email) y
ResetPassword.tsx (nueva contraseña con token). Se elimina el reCAPTCHA roto; se
puede añadir uno propio si se aportan claves.

Verificado en producción: los 3 flujos devuelven éxito genérico; reset valida
token y contraseñas; token válido no provoca 500.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 21:00:42 +00:00
parent 45f48c2799
commit 8920585b24
14 changed files with 511 additions and 52 deletions
+29
View File
@@ -0,0 +1,29 @@
<!DOCTYPE html>
{% include 'partials/head.html' %}
{% include 'partials/header.html' %}
{% include 'partials/video.html' %}
{% load django_vite %}
<div class="main-page">
<div class="middle-content">
<div class="body-content">
<div class="title-content">
<h1>Restablecer contraseña</h1>
</div>
<div class="box-content">
<!-- Isla React (Vite): fija la nueva contraseña con el token del enlace.
POST a {% url 'reset_password' %} (JSON) -> re-deriva el verifier bnet. -->
<div id="reset-password-app"
data-csrf="{{ csrf_token }}"
data-valid="{{ valid|yesno:'true,false' }}"
data-token="{{ token }}"
data-reset-url="{% url 'reset_password' %}"
data-recover-url="{% url 'recover' %}"></div>
{% vite_asset 'src/entries/reset_password.tsx' %}
</div>
</div>
</div>
</div>
{% include 'partials/social.html' %}
{% include 'partials/footer.html' %}
{% include 'partials/final.html' %}
+34
View File
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="es">
<head><meta charset="utf-8"></head>
<body style="margin:0;padding:0;background:#1b120b;font-family:Arial,Helvetica,sans-serif;color:#e8dccb;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#1b120b;padding:24px 0;">
<tr>
<td align="center">
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="max-width:600px;width:100%;background:#241812;border:1px solid #4a3320;border-radius:8px;">
<tr>
<td style="padding:28px 32px;">
<h1 style="margin:0 0 8px;font-size:20px;color:#d79602;">{{ NOMBRE_SERVIDOR }}</h1>
<h2 style="margin:0 0 16px;font-size:16px;color:#e8dccb;">Tus cuentas de juego</h2>
<p style="margin:0 0 12px;line-height:1.5;">Hola,</p>
<p style="margin:0 0 16px;line-height:1.5;">Estas son las cuentas de juego asociadas a tu cuenta Battle.net (<strong>{{ email }}</strong>). Recuerda: para iniciar sesión en la web usas tu <strong>correo electrónico</strong>.</p>
<table role="presentation" cellpadding="0" cellspacing="0" style="width:100%;border-collapse:collapse;margin:0 0 16px;">
{% for a in accounts %}
<tr>
<td style="padding:10px 14px;border:1px solid #4a3320;background:#2c1e14;color:#e8dccb;">{{ a.username }}</td>
</tr>
{% empty %}
<tr>
<td style="padding:10px 14px;border:1px solid #4a3320;background:#2c1e14;color:#b1997f;">No hay cuentas de juego asociadas todavía.</td>
</tr>
{% endfor %}
</table>
<p style="margin:0;line-height:1.5;font-size:13px;color:#b1997f;">Si no has solicitado esta información, ignora este correo.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
+29
View File
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="es">
<head><meta charset="utf-8"></head>
<body style="margin:0;padding:0;background:#1b120b;font-family:Arial,Helvetica,sans-serif;color:#e8dccb;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#1b120b;padding:24px 0;">
<tr>
<td align="center">
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="max-width:600px;width:100%;background:#241812;border:1px solid #4a3320;border-radius:8px;">
<tr>
<td style="padding:28px 32px;">
<h1 style="margin:0 0 8px;font-size:20px;color:#d79602;">{{ NOMBRE_SERVIDOR }}</h1>
<h2 style="margin:0 0 16px;font-size:16px;color:#e8dccb;">Restablecer contraseña</h2>
<p style="margin:0 0 12px;line-height:1.5;">Hola,</p>
<p style="margin:0 0 12px;line-height:1.5;">Hemos recibido una solicitud para restablecer la contraseña de la cuenta Battle.net asociada a <strong>{{ email }}</strong>.</p>
<p style="margin:0 0 20px;line-height:1.5;">Pulsa el botón para elegir una nueva contraseña. El enlace caduca en 1 hora.</p>
<p style="margin:0 0 20px;">
<a href="{{ reset_link }}" style="display:inline-block;padding:12px 22px;background:#d79602;color:#1b120b;text-decoration:none;border-radius:6px;font-weight:bold;">Restablecer contraseña</a>
</p>
<p style="margin:0 0 8px;line-height:1.5;font-size:13px;color:#b1997f;">Si el botón no funciona, copia esta dirección en tu navegador:</p>
<p style="margin:0 0 20px;line-height:1.5;font-size:13px;word-break:break-all;"><a href="{{ reset_link }}" style="color:#2471a9;">{{ reset_link }}</a></p>
<p style="margin:0;line-height:1.5;font-size:13px;color:#b1997f;">Si no has solicitado este cambio, ignora este correo: tu contraseña no se modificará.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
+11 -52
View File
@@ -1,3 +1,4 @@
{% load django_vite %}
<div class="main-page">
<div class="middle-content">
<div class="body-content">
@@ -7,15 +8,15 @@
<div class="body-box-content justified">
<span>Si has olvidado la contraseña de la cuenta:</span>
<p>- Selecciona la opción 'Contraseña'.</p>
<p>- Escribe Nombre de usuario.</p>
<p>- Escribe el correo electrónico de la cuenta.</p>
<p>- Un correo será enviado con un enlace para generar una contraseña nueva.</p>
<br>
<span>Si has olvidado el nombre de la cuenta:</span>
<span>Si has olvidado con qué cuentas de juego cuentas:</span>
<p>- Selecciona la opción 'Nombre de cuenta'.</p>
<p>- Escribe el correo electrónico.</p>
<p>- Un correo será enviado con todas las cuentas ligadas al correo.</p>
<br>
<span>Si no has recibido en enlace de activación:</span>
<span>Si no has recibido el enlace de activación:</span>
<p>- Selecciona la opción 'Enlace de activación'.</p>
<p>- Escribe el correo electrónico.</p>
<p>- Un correo será enviado con el enlace de activación.</p>
@@ -25,57 +26,15 @@
<div class="box-content">
<div class="title-box-content"><h2>Solicitud de información</h2></div>
<div class="body-box-content centered">
<p>Escoge la opción acorde a la información que quieres recuperar</p><p>
<br>
<select onchange="updateForm(this.value)" id="selection">
<option value="recover-accountpassword-form" selected="selected">Contraseña</option>
<option value="recover-accountname-form">Nombre de cuenta</option>
<option value="recover-activationlink-form">Enlace de activación</option>
</select>
</p><form action="" method="POST" id="nw-recover-accountpassword-form" accept-charset="utf-8" style="">
<table class="middle-center-table">
<tbody><tr>
<td><input type="text" maxlength="20" name="username" id="username" placeholder="Nombre de usuario"></td>
</tr>
<tr>
<td><div class="g-recaptcha g-recaptcha-div" id="gcaptcha" data-theme="dark" data-sitekey="6LcsJH4UAAAAAKqW0y4c-OVFijZjtZqkadRlpbRI"><div style="width: 304px; height: 78px;"><div><iframe title="reCAPTCHA" width="304" height="78" role="presentation" name="a-qxqlxz4xlesu" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox allow-storage-access-by-user-activation" src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=6LcsJH4UAAAAAKqW0y4c-OVFijZjtZqkadRlpbRI&amp;co=aHR0cHM6Ly91bHRpbW93b3cuY29tOjQ0Mw..&amp;hl=en&amp;v=-ZG7BC9TxCVEbzIO2m429usb&amp;theme=dark&amp;size=normal&amp;cb=m8d6xkv8z4oz"></iframe></div><textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea></div></div></td>
</tr>
<tr>
<td><button type="submit" name="recover" class="recover-button" data-id="RecuperarInfo">Solicitar</button></td>
</tr>
</tbody></table>
</form>
<form action="" method="POST" id="nw-recover-accountname-form" accept-charset="utf-8" style="display: none;">
<table class="middle-center-table">
<tbody><tr>
<td><input type="email" name="email" id="email" placeholder="Correo electrónico"></td>
</tr>
<tr>
<td><div class="g-recaptcha g-recaptcha-div" id="gcaptcha" data-theme="dark" data-sitekey="6LcsJH4UAAAAAKqW0y4c-OVFijZjtZqkadRlpbRI"><div style="width: 304px; height: 78px;"><div><iframe title="reCAPTCHA" width="304" height="78" role="presentation" name="a-xflp6m78yzp" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox allow-storage-access-by-user-activation" src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=6LcsJH4UAAAAAKqW0y4c-OVFijZjtZqkadRlpbRI&amp;co=aHR0cHM6Ly91bHRpbW93b3cuY29tOjQ0Mw..&amp;hl=en&amp;v=-ZG7BC9TxCVEbzIO2m429usb&amp;theme=dark&amp;size=normal&amp;cb=3s51wzqngwmx"></iframe></div><textarea id="g-recaptcha-response-1" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea></div></div></td>
</tr>
<tr>
<td><button type="submit" name="recover" class="recover-button" data-id="RecuperarInfo">Solicitar</button></td>
</tr>
</tbody></table>
</form>
<form action="" method="POST" id="nw-recover-activationlink-form" accept-charset="utf-8" style="display: none;">
<table class="middle-center-table">
<tbody><tr>
<td><input type="text" maxlength="20" name="username" id="username" placeholder="Nombre de usuario"></td>
</tr>
<tr>
<td><div class="g-recaptcha g-recaptcha-div" id="gcaptcha" data-theme="dark" data-sitekey="6LcsJH4UAAAAAKqW0y4c-OVFijZjtZqkadRlpbRI"><div style="width: 304px; height: 78px;"><div><iframe title="reCAPTCHA" width="304" height="78" role="presentation" name="a-sv4k9abynly6" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox allow-storage-access-by-user-activation" src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=6LcsJH4UAAAAAKqW0y4c-OVFijZjtZqkadRlpbRI&amp;co=aHR0cHM6Ly91bHRpbW93b3cuY29tOjQ0Mw..&amp;hl=en&amp;v=-ZG7BC9TxCVEbzIO2m429usb&amp;theme=dark&amp;size=normal&amp;cb=ujz7erfdzg8x"></iframe></div><textarea id="g-recaptcha-response-2" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea></div><iframe style="display: none;"></iframe></div></td>
</tr>
<tr>
<td><button type="submit" name="recover" class="recover-button" data-id="RecuperarInfo">Solicitar</button></td>
</tr>
</tbody></table>
</form>
<hr>
<div class="alert-message" id="recover-response"></div>
<!-- Isla React (Vite): recuperación de cuenta (contraseña / nombre de
cuenta / reenvío de activación). POST a {% url 'recover' %} (JSON). -->
<div id="recover-app"
data-csrf="{{ csrf_token }}"
data-recover-url="{% url 'recover' %}"></div>
{% vite_asset 'src/entries/recover.tsx' %}
<br>
</div>
</div>
</div>
</div>
</div>
</div>