diff --git a/web-next/app/[locale]/my-account/page.tsx b/web-next/app/[locale]/my-account/page.tsx
index 9b5be78..28abe7a 100644
--- a/web-next/app/[locale]/my-account/page.tsx
+++ b/web-next/app/[locale]/my-account/page.tsx
@@ -2,6 +2,7 @@ import { getTranslations, setRequestLocale } from 'next-intl/server'
import { redirect, Link } from '@/i18n/navigation'
import { getSession } from '@/lib/session'
import { getRealmName, realmSlug } from '@/lib/realm'
+import { gameAccountDisplayName } from '@/lib/bnet'
import { getAccountDashboard, getAccountRank } from '@/lib/account'
import { reconcileSumUpCheckouts } from '@/lib/sumup'
import { getGameAccounts } from '@/lib/auth'
@@ -22,13 +23,6 @@ function maskEmail(e: string): string {
return `${visible}***@${domain}`
}
-// Nombre visible de la cuenta de juego: «15#1» → «WOW1» (el nº tras # es la
-// cuenta de juego; con varias serían WOW1, WOW2, WOW3…).
-function wowAccountName(username: string): string {
- const i = username.indexOf('#')
- return i >= 0 ? `WOW${username.slice(i + 1)}` : username
-}
-
const ICONS = '/ns-themes/ns-ryu/ns-images/ns-icons'
export default async function AccountPage({ params }: { params: Promise<{ locale: string }> }) {
@@ -67,7 +61,7 @@ export default async function AccountPage({ params }: { params: Promise<{ locale
{t('regMail')}: {maskEmail(data.regMail)}
diff --git a/web-next/lib/bnet.ts b/web-next/lib/bnet.ts index 1f90539..802e187 100644 --- a/web-next/lib/bnet.ts +++ b/web-next/lib/bnet.ts @@ -147,6 +147,24 @@ export function makeGameAccountUsername(bnetId: number, index = 1): string { return `${bnetId}#${index}` } +/** + * Inverso de `makeGameAccountUsername` para enseñárselo al usuario: «15#1» → «WOW1». + * El número tras # es la cuenta de juego (WOW1…WOW8). El `15#1` es interno y no le + * dice nada a nadie. + */ +export function gameAccountDisplayName(username: string): string { + const i = username.indexOf('#') + return i >= 0 ? `WOW${username.slice(i + 1)}` : username +} + +/** + * Solo se admiten cuentas de Gmail. Lleva la `i` a propósito: sin ella + * `NOVAWOW86@GMAIL.COM` se rechazaba, y es justo como sale el correo en los + * mensajes que enviamos, así que quien lo copiara de ahí no podía ni registrarse + * ni recuperar la cuenta. El dominio del correo NO distingue mayúsculas. + */ +export const GMAIL_RE = /^[a-zA-Z0-9._%+-]+@gmail\.com$/i + /** * Cuentas de juego por cuenta Battle.net (WoW1…WoW8). Vive aquí, y no en la ruta * que la aplica, para que el correo de activación cite el límite REAL: el texto diff --git a/web-next/lib/change-email.ts b/web-next/lib/change-email.ts index 5268684..c39d30c 100644 --- a/web-next/lib/change-email.ts +++ b/web-next/lib/change-email.ts @@ -2,13 +2,12 @@ import crypto from 'node:crypto' import type { RowDataPacket, ResultSetHeader } from 'mysql2' import { db, DB } from './db' import { authenticate } from './auth' -import { bnetMakeRegistration, normalizeEmail } from './bnet' +import { bnetMakeRegistration, normalizeEmail, GMAIL_RE } from './bnet' import { checkSecurityToken } from './security-token' import { sendMail } from './mail' import { confirmNewEmailHtml, confirmOldEmailHtml } from './emails' import type { SessionData } from './session' -const GMAIL_RE = /^[a-zA-Z0-9._%+-]+@gmail\.com$/ export interface Result { success: boolean diff --git a/web-next/lib/emails.ts b/web-next/lib/emails.ts index 01c453c..ea4ef43 100644 --- a/web-next/lib/emails.ts +++ b/web-next/lib/emails.ts @@ -21,7 +21,7 @@ * entra con el correo, no con un usuario). */ -import { MAX_GAME_ACCOUNTS } from './bnet' +import { MAX_GAME_ACCOUNTS, gameAccountDisplayName } from './bnet' const SERVER_NAME = 'NightSpire' @@ -275,9 +275,10 @@ export function passwordResetEmailHtml(email: string, link: string, locale = 'es } /** `account_names.html` — recordatorio de cuentas de juego. */ +/** `accounts` son los usernames internos («17#1»); aquí se muestran como «WOW1». */ export function accountNamesEmailHtml(email: string, accounts: string[], locale = 'es'): string { const list = accounts.length - ? pData(accounts.map((a) => `Cuenta: ${esc(a)}`).join('