Fix login: seed.js creates admin user, run seed before server start
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { sequelize, connectDB } = require('./config/database');
|
||||
const Block = require('./models/Block');
|
||||
const User = require('./models/User');
|
||||
|
||||
const eventBlocks = [
|
||||
{
|
||||
@@ -114,6 +115,12 @@ const eventBlocks = [
|
||||
async function seed() {
|
||||
try {
|
||||
await connectDB();
|
||||
// Create admin user if not exists
|
||||
const existingUser = await User.findOne({ where: { email: 'admin@cad.local' } });
|
||||
if (!existingUser) {
|
||||
await User.create({ email: 'admin@cad.local', password: 'admin123' });
|
||||
console.log('Admin user created: admin@cad.local / admin123');
|
||||
}
|
||||
// Clear existing blocks
|
||||
await Block.destroy({ where: {} });
|
||||
console.log('Existing blocks cleared.');
|
||||
|
||||
Reference in New Issue
Block a user