Admin: corregir columnas de account_access + enlace al panel en la cuenta

- 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) <noreply@anthropic.com>
This commit is contained in:
2026-07-13 01:42:04 +00:00
parent 95df2e029d
commit 1a45d48412
7 changed files with 20 additions and 6 deletions
+12
View File
@@ -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
<LogoutButton className="rounded border border-amber-900/60 px-3 py-1 text-sm text-amber-200 hover:text-amber-400" />
</div>
{admin && (
<Link
href="/admin"
className="mb-6 flex items-center justify-between gap-3 rounded-lg border border-nw-gold/50 bg-nw-gold/10 px-4 py-3 text-sm font-semibold text-nw-gold-light transition hover:bg-nw-gold/20"
>
<span>🛡 {t('adminPanel')}</span>
<span aria-hidden></span>
</Link>
)}
<div className="grid gap-4 sm:grid-cols-2">
<section className={card}>
<div className="space-y-1 text-sm">
+1 -1
View File
@@ -20,7 +20,7 @@ export async function searchAccounts(query: string, limit = 30): Promise<Account
const like = `%${query}%`
const [rows] = await db(DB.auth).query<RowDataPacket[]>(
`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
+1 -1
View File
@@ -16,7 +16,7 @@ export async function isAdmin(session: SessionData): Promise<boolean> {
try {
const level = Number(process.env.ADMIN_GMLEVEL || 3)
const [rows] = await db(DB.auth).query<RowDataPacket[]>(
'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
+1 -1
View File
@@ -10,7 +10,7 @@ export async function getGmlevel(accountId: number | undefined): Promise<number>
if (!accountId) return 0
try {
const [rows] = await db(DB.auth).query<RowDataPacket[]>(
'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
+1 -1
View File
@@ -259,7 +259,7 @@ export async function getForumProfile(username: string): Promise<ForumProfile> {
if (acc[0]) {
profile.joindate = acc[0].joindate ? new Date(acc[0].joindate).toISOString() : null
const [ga] = await db(DB.auth).query<RowDataPacket[]>(
'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
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -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",