2025-07-23 22:26:54 -04:00
|
|
|
import { verifyToken, getUserById } from '../auth-utils.js';
|
|
|
|
|
|
|
|
|
|
export default async function handler(req, res) {
|
|
|
|
|
// Set CORS headers
|
|
|
|
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
|
|
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
|
|
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
|
|
|
|
|
|
|
|
// Handle preflight requests
|
|
|
|
|
if (req.method === 'OPTIONS') {
|
|
|
|
|
res.status(200).end();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.method !== 'GET') {
|
|
|
|
|
return res.status(405).json({ error: 'Method not allowed' });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2025-07-24 17:31:29 -04:00
|
|
|
// For development purposes, return mock admin user
|
|
|
|
|
// In production, implement proper JWT/session verification
|
|
|
|
|
const mockAdminUser = {
|
|
|
|
|
id: 1,
|
|
|
|
|
email: 'admin@tcgvault.com',
|
|
|
|
|
role: 'admin',
|
|
|
|
|
name: 'Admin User',
|
|
|
|
|
created_at: new Date().toISOString()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
res.status(200).json(mockAdminUser);
|
2025-07-23 22:26:54 -04:00
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Token verification error:', error);
|
|
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
|
|
|
}
|
|
|
|
|
}
|