Skip to content

Commit

Permalink
fix: change the welcome mail content
Browse files Browse the repository at this point in the history
  • Loading branch information
amanramoliya committed Aug 16, 2023
1 parent bf3bf1f commit 941bbc5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions backend/src/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -198,13 +199,9 @@ export class UserService {
async addUser(users: AddUserDto[]): Promise<number> {
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,
Expand All @@ -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: `<b>welcome to Learning Planner</b> <p>Your password is ${userMails[i].password}</p>`,
html:
userData[i].roles === Role.Employee
? `<b>welcome to Learning Planner</b> <p>https://incubyte-learningplanner.netlify.app </p> `
: ` <b>welcome to Learning Planner You are an Admin</b> <p>Admin: https://admin-incubyte-learningplanner.netlify.app </p><br/><br/><p>Employee: https://incubyte-learningplanner.netlify.app </p>`,
});
}
return result.count;
Expand Down

0 comments on commit 941bbc5

Please sign in to comment.