deckhearth/scripts/create-test-users.js

45 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

#!/usr/bin/env node
import { config } from 'dotenv';
import { sql } from '@vercel/postgres';
import bcrypt from 'bcryptjs';
// Load environment variables
config({ path: '.env.local' });
async function createTestUsers() {
try {
console.log('<27><> Creating test users...\n');
// Create Alice (collaborator)
const alicePassword = await bcrypt.hash('alice123', 12);
await sql`
INSERT INTO users (email, password, role)
VALUES ('alice@tcgvault.com', ${alicePassword}, 'user')
ON CONFLICT (email) DO NOTHING
`;
console.log('✅ Created Alice (alice@tcgvault.com / alice123)');
// Create Bob (collaborator)
const bobPassword = await bcrypt.hash('bob123', 12);
await sql`
INSERT INTO users (email, password, role)
VALUES ('bob@tcgvault.com', ${bobPassword}, 'user')
ON CONFLICT (email) DO NOTHING
`;
console.log('✅ Created Bob (bob@tcgvault.com / bob123)');
console.log('\n🎉 Test users created successfully!');
console.log('\n👥 Available Test Accounts:');
console.log(' 1. admin@tcgvault.com / admin123 (Admin)');
console.log(' 2. alice@tcgvault.com / alice123 (User)');
console.log(' 3. bob@tcgvault.com / bob123 (User)');
} catch (error) {
console.error('❌ Failed to create test users:', error.message);
process.exit(1);
}
}
createTestUsers();