From 941bbc57a07049483eba74110902a8297d2125d9 Mon Sep 17 00:00:00 2001 From: amanramoliya <19ceuot073@ddu.ac.in> Date: Wed, 16 Aug 2023 10:57:33 +0530 Subject: [PATCH] fix: change the welcome mail content --- backend/src/user/user.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 97551b4f..0a1a718a 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -1,3 +1,4 @@ +import { Role } from '@/auth/role.enum'; import { PrismaService } from '@Prisma/prisma.service'; import { UpdateUserDto } from '@User/dto/updateUser.dto'; import { MailerService } from '@nestjs-modules/mailer'; @@ -198,13 +199,9 @@ export class UserService { async addUser(users: AddUserDto[]): Promise { const userData = []; - const userMails = []; if (users) { for (let i = 0; i < users.length; i++) { - const password = 'Incubyte' + '@' + Math.floor(Math.random() * 1000); - const saltOrRounds = 10; - const hash = bcrypt.hashSync(password, saltOrRounds); - userMails.push({ email: users[i].email, password: password }); + const hash = bcrypt.hashSync('password', 10); userData.push({ ...users[i], password: hash, @@ -217,12 +214,15 @@ export class UserService { const result = await this.prismaService.user.createMany({ data: userData, }); - for (let i = 0; i < userMails.length; i++) { + for (let i = 0; i < userData.length; i++) { this.mailerService.sendMail({ - to: userMails[i].email, + to: userData[i].email, from: 'a.learningplanner@gmail.com', subject: 'Account created LearningPlanner@Incubyte', - html: `welcome to Learning Planner

Your password is ${userMails[i].password}

`, + html: + userData[i].roles === Role.Employee + ? `welcome to Learning Planner

https://incubyte-learningplanner.netlify.app

` + : ` welcome to Learning Planner You are an Admin

Admin: https://admin-incubyte-learningplanner.netlify.app



Employee: https://incubyte-learningplanner.netlify.app

`, }); } return result.count;