diff --git a/scripts/create-admin-better-auth.js b/scripts/create-admin-better-auth.js index 1726126..15b3d3a 100644 --- a/scripts/create-admin-better-auth.js +++ b/scripts/create-admin-better-auth.js @@ -1,5 +1,5 @@ const { PrismaClient } = require('@prisma/client'); -const bcrypt = require('bcryptjs'); +const bcrypt = require('bcrypt'); const prisma = new PrismaClient(); diff --git a/scripts/create-admin.js b/scripts/create-admin.js deleted file mode 100644 index e475a1e..0000000 --- a/scripts/create-admin.js +++ /dev/null @@ -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(); diff --git a/scripts/list-users.js b/scripts/list-users.js index f152b3f..ef8851f 100644 --- a/scripts/list-users.js +++ b/scripts/list-users.js @@ -19,7 +19,7 @@ async function listUsers() { console.log(`ID: ${user.id}`); console.log(` Email: ${user.email}`); 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(''); }); diff --git a/scripts/register-admin.sh b/scripts/register-admin.sh deleted file mode 100755 index 83aeb45..0000000 --- a/scripts/register-admin.sh +++ /dev/null @@ -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