fix
This commit is contained in:
29
scripts/add-user.js
Normal file
29
scripts/add-user.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function createUser() {
|
||||
try {
|
||||
const hashedPassword = await bcrypt.hash('gk1510!', 10);
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email: 'gregor@klevze.si',
|
||||
password: hashedPassword,
|
||||
name: 'Gregor',
|
||||
surname: 'Klevže',
|
||||
active: true,
|
||||
role: 'admin',
|
||||
},
|
||||
});
|
||||
|
||||
console.log('User created successfully:', user);
|
||||
} catch (error) {
|
||||
console.error('Error creating user:', error);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
createUser();
|
||||
23
scripts/add-user.sql
Normal file
23
scripts/add-user.sql
Normal file
@ -0,0 +1,23 @@
|
||||
-- Add user: Gregor Klevže
|
||||
-- Note: In a real application, you would use proper password hashing,
|
||||
-- but for direct SQL insertion we're using a placeholder password that you should change immediately
|
||||
INSERT INTO `User` (
|
||||
`email`,
|
||||
`password`,
|
||||
`name`,
|
||||
`surname`,
|
||||
`active`,
|
||||
`role`,
|
||||
`createdAt`,
|
||||
`updatedAt`
|
||||
)
|
||||
VALUES (
|
||||
'gregor@klevze.si',
|
||||
'gk1510!', -- This should be hashed in a real application
|
||||
'Gregor',
|
||||
'Klevže',
|
||||
true,
|
||||
'admin',
|
||||
NOW(),
|
||||
NOW()
|
||||
);
|
||||
29
scripts/add-user.ts
Normal file
29
scripts/add-user.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { PrismaClient } from '../src/generated/prisma';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function createUser() {
|
||||
try {
|
||||
const hashedPassword = await bcrypt.hash('gk1510!', 10);
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email: 'gregor@klevze.si',
|
||||
password: hashedPassword,
|
||||
name: 'Gregor',
|
||||
surname: 'Klevže',
|
||||
active: true,
|
||||
role: 'admin',
|
||||
},
|
||||
});
|
||||
|
||||
console.log('User created successfully:', user);
|
||||
} catch (error) {
|
||||
console.error('Error creating user:', error);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
createUser();
|
||||
Reference in New Issue
Block a user