From 1a45d48412037596d02f58e1a2ec91090594c565 Mon Sep 17 00:00:00 2001 From: adevopg Date: Mon, 13 Jul 2026 01:42:04 +0000 Subject: [PATCH] Admin: corregir columnas de account_access + enlace al panel en la cuenta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Este build de AzerothCore usa account_access(AccountID, SecurityLevel), no el clásico (id, gmlevel). Se corrigen las 4 consultas (admin.ts, forum-perm.ts, forum.ts, admin-users.ts) -> isAdmin/forumIsModerator/gmlevel ahora funcionan. - account page: enlace destacado al Panel de administración, visible solo si isAdmin. - i18n es/en: Account.adminPanel. Verificado: build OK; cuenta de prueba con SecurityLevel 3 (>= ADMIN_GMLEVEL) es admin. Co-Authored-By: Claude Opus 4.8 (1M context) --- web-next/app/[locale]/account/page.tsx | 12 ++++++++++++ web-next/lib/admin-users.ts | 2 +- web-next/lib/admin.ts | 2 +- web-next/lib/forum-perm.ts | 2 +- web-next/lib/forum.ts | 2 +- web-next/messages/en.json | 3 ++- web-next/messages/es.json | 3 ++- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/web-next/app/[locale]/account/page.tsx b/web-next/app/[locale]/account/page.tsx index 3264bec..6c21e89 100644 --- a/web-next/app/[locale]/account/page.tsx +++ b/web-next/app/[locale]/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 { getAccountDashboard } from '@/lib/account' +import { isAdmin } from '@/lib/admin' import { LogoutButton } from '@/components/LogoutButton' export const dynamic = 'force-dynamic' @@ -16,6 +17,7 @@ export default async function AccountPage({ params }: { params: Promise<{ locale if (!session.username) redirect({ href: '/select-account', locale }) const data = await getAccountDashboard(session) + const admin = await isAdmin(session) const card = 'nw-card' @@ -26,6 +28,16 @@ export default async function AccountPage({ params }: { params: Promise<{ locale + {admin && ( + + 🛡️ {t('adminPanel')} + + + )} +
diff --git a/web-next/lib/admin-users.ts b/web-next/lib/admin-users.ts index 91b135e..a222843 100644 --- a/web-next/lib/admin-users.ts +++ b/web-next/lib/admin-users.ts @@ -20,7 +20,7 @@ export async function searchAccounts(query: string, limit = 30): Promise( `SELECT a.id, a.username, a.email, a.last_ip, a.last_login, a.online, - (SELECT MAX(x.gmlevel) FROM account_access x WHERE x.id = a.id) AS gmlevel, + (SELECT MAX(x.SecurityLevel) FROM account_access x WHERE x.AccountID = a.id) AS gmlevel, b.banreason AS ban_reason, b.bandate, b.unbandate FROM account a LEFT JOIN account_banned b ON b.id = a.id AND b.active = 1 diff --git a/web-next/lib/admin.ts b/web-next/lib/admin.ts index f4f7552..139aecf 100644 --- a/web-next/lib/admin.ts +++ b/web-next/lib/admin.ts @@ -16,7 +16,7 @@ export async function isAdmin(session: SessionData): Promise { try { const level = Number(process.env.ADMIN_GMLEVEL || 3) const [rows] = await db(DB.auth).query( - 'SELECT gmlevel FROM account_access WHERE id = ? ORDER BY gmlevel DESC LIMIT 1', + 'SELECT SecurityLevel AS gmlevel FROM account_access WHERE AccountID = ? ORDER BY SecurityLevel DESC LIMIT 1', [session.accountId ?? 0], ) if (rows[0] && Number(rows[0].gmlevel) >= level) return true diff --git a/web-next/lib/forum-perm.ts b/web-next/lib/forum-perm.ts index c50f91f..6cd3dc8 100644 --- a/web-next/lib/forum-perm.ts +++ b/web-next/lib/forum-perm.ts @@ -10,7 +10,7 @@ export async function getGmlevel(accountId: number | undefined): Promise if (!accountId) return 0 try { const [rows] = await db(DB.auth).query( - 'SELECT MAX(gmlevel) AS lvl FROM account_access WHERE id = ?', + 'SELECT MAX(SecurityLevel) AS lvl FROM account_access WHERE AccountID = ?', [accountId], ) return rows[0] && rows[0].lvl != null ? Number(rows[0].lvl) : 0 diff --git a/web-next/lib/forum.ts b/web-next/lib/forum.ts index 7496971..dbfb40c 100644 --- a/web-next/lib/forum.ts +++ b/web-next/lib/forum.ts @@ -259,7 +259,7 @@ export async function getForumProfile(username: string): Promise { if (acc[0]) { profile.joindate = acc[0].joindate ? new Date(acc[0].joindate).toISOString() : null const [ga] = await db(DB.auth).query( - 'SELECT MAX(gmlevel) AS lvl FROM account_access WHERE id = ?', + 'SELECT MAX(SecurityLevel) AS lvl FROM account_access WHERE AccountID = ?', [acc[0].id], ) profile.gmlevel = ga[0]?.lvl != null ? Number(ga[0].lvl) : 0 diff --git a/web-next/messages/en.json b/web-next/messages/en.json index 46d02f6..eeb30d2 100644 --- a/web-next/messages/en.json +++ b/web-next/messages/en.json @@ -80,7 +80,8 @@ "svcChangeEmail": "Change email", "svcVote": "Vote (points)", "svcRecruit": "Recruit a friend", - "svcStore": "Store (Battlepay)" + "svcStore": "Store (Battlepay)", + "adminPanel": "Admin panel" }, "SelectAccount": { "title": "Select your game account", diff --git a/web-next/messages/es.json b/web-next/messages/es.json index 8f820ef..01e5e5e 100644 --- a/web-next/messages/es.json +++ b/web-next/messages/es.json @@ -80,7 +80,8 @@ "svcChangeEmail": "Cambiar email", "svcVote": "Votar (puntos)", "svcRecruit": "Recluta a un amigo", - "svcStore": "Tienda (Battlepay)" + "svcStore": "Tienda (Battlepay)", + "adminPanel": "Panel de administración" }, "SelectAccount": { "title": "Selecciona tu cuenta de juego",