diff --git a/pages/api/auth-utils.js b/pages/api/auth-utils.js index 3685d0c..5657917 100644 --- a/pages/api/auth-utils.js +++ b/pages/api/auth-utils.js @@ -1,14 +1,15 @@ import jwt from 'jsonwebtoken'; -import bcrypt from 'bcryptjs'; import { sql } from '@vercel/postgres'; const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key'; export async function hashPassword(password) { + const bcrypt = await import('bcryptjs'); return await bcrypt.hash(password, 12); } export async function verifyPassword(password, hashedPassword) { + const bcrypt = await import('bcryptjs'); return await bcrypt.compare(password, hashedPassword); } diff --git a/pages/api/setup-database.js b/pages/api/setup-database.js index c5af2bb..2a4c799 100644 --- a/pages/api/setup-database.js +++ b/pages/api/setup-database.js @@ -125,7 +125,7 @@ export default async function handler(req, res) { `; // Create a default admin user - const bcrypt = require('bcryptjs'); + const bcrypt = await import('bcryptjs'); const hashedPassword = await bcrypt.hash('admin123', 12); await sql` @@ -137,7 +137,11 @@ export default async function handler(req, res) { res.status(200).json({ success: true, message: 'Database setup completed successfully!', - tables: ['users', 'cards', 'user_cards', 'collections', 'collection_cards', 'decks', 'deck_cards'] + tables: ['users', 'cards', 'user_cards', 'collections', 'collection_cards', 'decks', 'deck_cards'], + adminUser: { + email: 'admin@tcgvault.com', + password: 'admin123' + } }); } catch (error) {