chore: update admin script to set site_admin role by default
This commit is contained in:
@@ -43,8 +43,17 @@ async function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
console.log('User exists, deleting...');
|
console.log('User exists, updating role to site_admin...');
|
||||||
await prisma.user.delete({ where: { id: existing.id } });
|
await prisma.user.update({
|
||||||
|
where: { id: existing.id },
|
||||||
|
data: { role: 'site_admin' }
|
||||||
|
});
|
||||||
|
console.log('✅ User role updated to site_admin (superuser)');
|
||||||
|
console.log('\nSuperuser created successfully!');
|
||||||
|
console.log('Email: david@dhg.lol');
|
||||||
|
console.log('Password: adminadmin');
|
||||||
|
console.log('Role: site_admin');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create user using Better Auth's internal method
|
// Create user using Better Auth's internal method
|
||||||
@@ -62,13 +71,13 @@ async function main() {
|
|||||||
console.log(' Name:', signUpResult.user.name);
|
console.log(' Name:', signUpResult.user.name);
|
||||||
console.log(' Password: adminadmin');
|
console.log(' Password: adminadmin');
|
||||||
|
|
||||||
// Update the user to have club_admin role
|
// Update the user to have site_admin role (superuser)
|
||||||
await prisma.user.update({
|
await prisma.user.update({
|
||||||
where: { id: signUpResult.user.id },
|
where: { id: signUpResult.user.id },
|
||||||
data: { role: 'club_admin' }
|
data: { role: 'site_admin' }
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('✅ User role updated to club_admin');
|
console.log('✅ User role updated to site_admin (superuser)');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Error:', error.message);
|
console.error('❌ Error:', error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user