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
+63
View File
@@ -0,0 +1,63 @@
const { PrismaClient } = require('@prisma/client');
const { betterAuth } = require('better-auth');
const { prismaAdapter } = require('better-auth/adapters/prisma');
const prisma = new PrismaClient();
// Create Better Auth instance
const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: 'sqlite',
}),
emailAndPassword: {
enabled: true,
},
baseURL: process.env.BETTER_AUTH_URL || 'http://localhost:3000',
});
async function main() {
try {
// Check if user exists
const existing = await prisma.user.findUnique({
where: { email: 'david@dhg.lol' }
});
if (existing) {
console.log('User exists, deleting...');
await prisma.user.delete({ where: { id: existing.id } });
}
// Create user using Better Auth's internal method
// Better Auth uses bcrypt internally for password hashing
const signUpResult = await auth.api.signUpEmail({
body: {
email: 'david@dhg.lol',
password: 'adminadmin',
name: 'David Admin',
},
});
console.log('✅ Admin user created via Better Auth API!');
console.log(' Email:', signUpResult.user.email);
console.log(' Name:', signUpResult.user.name);
console.log(' Password: adminadmin');
// Update the user to have club_admin role
await prisma.user.update({
where: { id: signUpResult.user.id },
data: { role: 'club_admin' }
});
console.log('✅ User role updated to club_admin');
} catch (error) {
console.error('❌ Error:', error.message);
if (error.errors) {
console.error(' Details:', error.errors);
}
} finally {
await prisma.$disconnect();
}
}
main();