diff --git a/backend/imk-backend/.env b/backend/imk-backend/.env index e97fbff..fed6ef1 100644 --- a/backend/imk-backend/.env +++ b/backend/imk-backend/.env @@ -16,5 +16,5 @@ SMTP_PORT=465 SMTP_USER=mailer@imk.mk SMTP_PASSWORD=76Avtostoperski76 SMTP_FROM=mailer@imk.mk -FRONTEND_URL=https://imk.mk +FRONTEND_URL=http://localhost:5173 ADMIN_EMAIL=petrovskidimitar@yandex.com \ No newline at end of file diff --git a/backend/imk-backend/src/admin/admin.service.ts b/backend/imk-backend/src/admin/admin.service.ts index fc7a562..a337d54 100644 --- a/backend/imk-backend/src/admin/admin.service.ts +++ b/backend/imk-backend/src/admin/admin.service.ts @@ -43,15 +43,22 @@ export class AdminService { } async createUser(createUserDto: CreateUserDto) { - const hashedPassword = await bcrypt.hash(createUserDto.password, 10); - - return this.prisma.user.create({ - data: { - ...createUserDto, - password: hashedPassword, - isAdmin: createUserDto.isAdmin, - }, - }); + try { + const hashedPassword = await bcrypt.hash(createUserDto.password, 10); + const user = await this.prisma.user.create({ + data: { ...createUserDto, password: hashedPassword}, + }); + try { + await this.emailService.sendWelcomeEmail(user.email, user.name ); + console.log('Welcome email sent successfully'); + } catch (error) { + console.log('Error sending welcome email:', error); + } + return user; + } catch (error) { + console.error('Error creating user:', error ); + throw error; + } } async updateDocument( diff --git a/backend/imk-backend/src/email/email.service.ts b/backend/imk-backend/src/email/email.service.ts index db2353e..733c331 100644 --- a/backend/imk-backend/src/email/email.service.ts +++ b/backend/imk-backend/src/email/email.service.ts @@ -10,13 +10,21 @@ export class EmailService { to: email, subject: 'Welcome to IMK Platform', html: ` -

Welcome ${name}!

-

Your account has been created successfully.

-

You can now login to access your documents.

-

Please use the following link to reset your password:

+
+

Welcome to IMK Platform!

+

Dear ${name},

+

Thank you for joining IMK Platform. Your account has been created successfully.

+

You can now log in to access your documents and start collaborating with your team.

+

If you have any questions or need assistance, please don't hesitate to contact our support team.

+
+ + Login to Your Account + +

Best regards,
IMK Team

- `, - +
+ `, }); }