fix: remove dead admin scripts and fix create-admin-better-auth.js

This commit is contained in:
2026-03-29 19:43:12 -07:00
parent b82116b06a
commit cdbab52541
4 changed files with 2 additions and 85 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
const { PrismaClient } = require('@prisma/client'); const { PrismaClient } = require('@prisma/client');
const bcrypt = require('bcryptjs'); const bcrypt = require('bcrypt');
const prisma = new PrismaClient(); const prisma = new PrismaClient();
-56
View File
@@ -1,56 +0,0 @@
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();
+1 -1
View File
@@ -19,7 +19,7 @@ async function listUsers() {
console.log(`ID: ${user.id}`); console.log(`ID: ${user.id}`);
console.log(` Email: ${user.email}`); console.log(` Email: ${user.email}`);
console.log(` Role: ${user.role}`); console.log(` Role: ${user.role}`);
console.log(` Player: ${user.player.name}`); console.log(` Player: ${user.player?.name || 'N/A'}`);
console.log(` Created: ${user.createdAt}`); console.log(` Created: ${user.createdAt}`);
console.log(''); console.log('');
}); });
-27
View File
@@ -1,27 +0,0 @@
#!/bin/bash
# Start the dev server in background
echo "Starting dev server..."
npm run dev > /tmp/next-auth-test.log 2>&1 &
SERVER_PID=$!
# Wait for server to start
sleep 8
# Try to register via API
echo "Attempting to register admin user..."
curl -X POST http://localhost:3000/api/auth/sign-up/email \
-H "Content-Type: application/json" \
-d '{
"email": "david@dhg.lol",
"password": "admin",
"name": "David Admin"
}' \
2>/dev/null
echo ""
echo "Checking if user was created..."
sqlite3 prisma/dev.db "SELECT email, role FROM users;"
# Cleanup
kill $SERVER_PID 2>/dev/null