nextjs-rewrite (#5)

Reviewed-on: #5
Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
2026-03-30 02:30:13 +00:00
committed by david
parent 1a9b3496e1
commit 123df671f5
160 changed files with 19293 additions and 1180 deletions
+56
View File
@@ -0,0 +1,56 @@
const { PrismaClient } = require('@prisma/client');
const crypto = require('crypto');
const prisma = new PrismaClient();
async function main() {
try {
// Use built-in crypto for quick hash (we'll update with proper one after)
const salt = crypto.randomBytes(16).toString('hex');
const hash = crypto.pbkdf2Sync('admin', salt, 10000, 64, 'sha256').toString('hex');
const fullHash = `${salt}:${hash}`;
// Generate cuid-like ID
const cuid = `clx_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
// Check if user exists
const existing = await prisma.user.findUnique({
where: { email: 'david@dhg.lol' }
});
if (existing) {
await prisma.user.delete({ where: { id: existing.id } });
}
// Create admin user
const user = await prisma.user.create({
data: {
id: cuid,
email: 'david@dhg.lol',
emailVerified: true,
role: 'club_admin',
name: 'David Admin',
accounts: {
create: {
id: `${cuid}_acc`,
accountId: `${cuid}_acc`,
providerId: 'credential',
password: fullHash,
}
}
}
});
console.log('✅ Admin user created successfully!');
console.log(' Email:', user.email);
console.log(' Role:', user.role);
console.log(' Password: admin');
} catch (error) {
console.error('❌ Error:', error.message);
} finally {
await prisma.$disconnect();
}
}
main();