From e8f2d3c2b41386fd787284071a408be7aea71121 Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 17 May 2024 15:00:17 +0200 Subject: [PATCH] :rocket: Updated seeds --- backend-nest/prisma/seed.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend-nest/prisma/seed.ts b/backend-nest/prisma/seed.ts index cacecb9..7818ec6 100644 --- a/backend-nest/prisma/seed.ts +++ b/backend-nest/prisma/seed.ts @@ -1,14 +1,17 @@ -import {PrismaClient, user_role} from '@prisma/client'; +import { PrismaClient, user_role } from '@prisma/client'; +import * as bcrypt from 'bcrypt'; const prisma = new PrismaClient(); async function main() { + const salt = await bcrypt.genSalt(); + const user1 = await prisma.user.upsert({ where: { email: 'alice@example.com' }, update: {}, create: { email: 'alice@example.com', - password: 'alicepassword', + password: await bcrypt.hash('alicepassword', salt), firstname: 'Alice', lastname: 'Doe', role: user_role.STUDENT, @@ -21,7 +24,7 @@ async function main() { update: {}, create: { email: 'bob@example.com', - password: 'bobpassword', + password: await bcrypt.hash('bobpassword', salt), firstname: 'Bob', lastname: 'Smith', role: user_role.ADMIN, @@ -31,7 +34,6 @@ async function main() { console.log({ user1, user2 }); } - main() .catch((e) => { console.error(e);