fix(leaderboard-service): fix AdminGuard role case sensitivity

The AdminAccount table stores roles in lowercase (admin, super_admin),
but AdminGuard was checking for uppercase (ADMIN, SUPER_ADMIN).
This caused 403 Forbidden errors for authenticated admin users.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-04 04:07:23 -08:00
parent cb59a964dd
commit aa58b9e745
1 changed files with 3 additions and 1 deletions

View File

@ -11,7 +11,9 @@ export class AdminGuard implements CanActivate {
} }
// 检查用户是否具有管理员角色 // 检查用户是否具有管理员角色
const isAdmin = user.role === 'ADMIN' || user.role === 'SUPER_ADMIN'; // 支持大小写: admin/ADMIN, super_admin/SUPER_ADMIN
const role = user.role?.toLowerCase();
const isAdmin = role === 'admin' || role === 'super_admin';
if (!isAdmin) { if (!isAdmin) {
throw new ForbiddenException('需要管理员权限'); throw new ForbiddenException('需要管理员权限');