Add authentication system and admin panel
- Implement JWT-based authentication with login/logout - Add user management routes and middleware - Create admin panel for managing words and categories - Add authentication store and API client - Update database schema with User model - Configure CORS and authentication middleware - Add login page and protected routes
This commit is contained in:
@@ -1,20 +1,48 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('🌱 Starting database seed...');
|
||||
|
||||
// Create a sample user
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email: 'demo@znakovni.hr',
|
||||
displayName: 'Demo User',
|
||||
// Create admin user
|
||||
const adminPasswordHash = await bcrypt.hash('admin123', 10);
|
||||
const admin = await prisma.user.upsert({
|
||||
where: { email: 'admin@znakovni.hr' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'admin@znakovni.hr',
|
||||
displayName: 'Administrator',
|
||||
passwordHash: adminPasswordHash,
|
||||
role: 'ADMIN',
|
||||
isActive: true,
|
||||
authProvider: 'local',
|
||||
},
|
||||
});
|
||||
|
||||
console.log('✅ Created demo user:', user.email);
|
||||
console.log('✅ Created admin user:', admin.email);
|
||||
console.log(' Email: admin@znakovni.hr');
|
||||
console.log(' Password: admin123');
|
||||
|
||||
// Create a demo regular user
|
||||
const demoPasswordHash = await bcrypt.hash('demo123', 10);
|
||||
const demoUser = await prisma.user.upsert({
|
||||
where: { email: 'demo@znakovni.hr' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'demo@znakovni.hr',
|
||||
displayName: 'Demo User',
|
||||
passwordHash: demoPasswordHash,
|
||||
role: 'USER',
|
||||
isActive: true,
|
||||
authProvider: 'local',
|
||||
},
|
||||
});
|
||||
|
||||
console.log('✅ Created demo user:', demoUser.email);
|
||||
console.log(' Email: demo@znakovni.hr');
|
||||
console.log(' Password: demo123');
|
||||
|
||||
// Add sample terms here in future phases
|
||||
console.log('✅ Seed completed successfully!');
|
||||
|
||||
Reference in New Issue
Block a user