security-history: mostrar WOW1 + cuenta Battle.net en vez de 15#1
La columna Usuario mostraba el nombre interno de la cuenta de juego (15#1). Ahora muestra la etiqueta WOW1 (nº tras #; con varias serían WOW2, WOW3…) y debajo la cuenta Battle.net (email), sin añadir columnas. Helper wowAccountLabel extraído a lib/bnet.ts (mismo criterio que my-account). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { setRequestLocale } from 'next-intl/server'
|
|||||||
import { redirect } from '@/i18n/navigation'
|
import { redirect } from '@/i18n/navigation'
|
||||||
import { getSession } from '@/lib/session'
|
import { getSession } from '@/lib/session'
|
||||||
import { getSecurityHistory } from '@/lib/security-history'
|
import { getSecurityHistory } from '@/lib/security-history'
|
||||||
|
import { wowAccountLabel } from '@/lib/bnet'
|
||||||
import { PageShell } from '@/components/PageShell'
|
import { PageShell } from '@/components/PageShell'
|
||||||
import { ServiceBox } from '@/components/ServiceBox'
|
import { ServiceBox } from '@/components/ServiceBox'
|
||||||
|
|
||||||
@@ -16,6 +17,21 @@ function fmt(d: Date): string {
|
|||||||
return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())} ${p(d.getDate())}-${p(d.getMonth() + 1)}-${d.getFullYear()}`
|
return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())} ${p(d.getDate())}-${p(d.getMonth() + 1)}-${d.getFullYear()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Celda «Usuario»: cuenta de juego (WOW1) + cuenta Battle.net (email) debajo. */
|
||||||
|
function UserCell({ label, bnet }: { label: string; bnet: string }) {
|
||||||
|
return (
|
||||||
|
<td>
|
||||||
|
<span>{label}</span>
|
||||||
|
{bnet && (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
<span className="second-brown small-font">{bnet}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default async function SecurityHistoryPage({ params }: { params: Promise<{ locale: string }> }) {
|
export default async function SecurityHistoryPage({ params }: { params: Promise<{ locale: string }> }) {
|
||||||
const { locale } = await params
|
const { locale } = await params
|
||||||
setRequestLocale(locale)
|
setRequestLocale(locale)
|
||||||
@@ -24,8 +40,9 @@ export default async function SecurityHistoryPage({ params }: { params: Promise<
|
|||||||
if (!session.bnetId) redirect({ href: '/login', locale })
|
if (!session.bnetId) redirect({ href: '/login', locale })
|
||||||
if (!session.username) redirect({ href: '/select-account', locale })
|
if (!session.username) redirect({ href: '/select-account', locale })
|
||||||
|
|
||||||
const displayUser = session.username || session.bnetEmail || '—'
|
const bnetEmail = session.bnetEmail || ''
|
||||||
const { activity, realm, web } = await getSecurityHistory(session.accountId!, displayUser, session.bnetEmail || '')
|
const displayUser = wowAccountLabel(session.username || '') // «15#1» → «WOW1»
|
||||||
|
const { activity, realm, web } = await getSecurityHistory(session.accountId!, displayUser, bnetEmail)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell title="Historial de seguridad">
|
<PageShell title="Historial de seguridad">
|
||||||
@@ -84,9 +101,7 @@ export default async function SecurityHistoryPage({ params }: { params: Promise<
|
|||||||
</tr>
|
</tr>
|
||||||
{activity.map((a, i) => (
|
{activity.map((a, i) => (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td>
|
<UserCell label={a.user} bnet={bnetEmail} />
|
||||||
<span>{a.user}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<span>{a.action}</span>
|
<span>{a.action}</span>
|
||||||
</td>
|
</td>
|
||||||
@@ -170,9 +185,7 @@ export default async function SecurityHistoryPage({ params }: { params: Promise<
|
|||||||
</tr>
|
</tr>
|
||||||
{web.map((c, i) => (
|
{web.map((c, i) => (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td>
|
<UserCell label={c.user} bnet={bnetEmail} />
|
||||||
<span>{c.user}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<span className={c.status === 'Conexión exitosa' ? '' : 'red-info2'}>{c.status}</span>
|
<span className={c.status === 'Conexión exitosa' ? '' : 'red-info2'}>{c.status}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -146,3 +146,13 @@ export function normalizeEmail(email: string): string {
|
|||||||
export function makeGameAccountUsername(bnetId: number, index = 1): string {
|
export function makeGameAccountUsername(bnetId: number, index = 1): string {
|
||||||
return `${bnetId}#${index}`
|
return `${bnetId}#${index}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nombre visible de una cuenta de juego: «15#1» → «WOW1» (el nº tras # es la
|
||||||
|
* cuenta de juego bajo la Battle.net; con varias serían WOW1, WOW2, WOW3…).
|
||||||
|
* El «15» es el id de la cuenta Battle.net y no debe mostrarse al usuario.
|
||||||
|
*/
|
||||||
|
export function wowAccountLabel(username: string): string {
|
||||||
|
const i = username.indexOf('#')
|
||||||
|
return i >= 0 ? `WOW${username.slice(i + 1)}` : username
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user