sending mail on user create working
This commit is contained in:
parent
847ed031db
commit
7ecb1fea2e
@ -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
|
||||
@ -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(
|
||||
|
||||
@ -10,13 +10,21 @@ export class EmailService {
|
||||
to: email,
|
||||
subject: 'Welcome to IMK Platform',
|
||||
html: `
|
||||
<h1>Welcome ${name}!</h1>
|
||||
<p>Your account has been created successfully.</p>
|
||||
<p>You can now login to access your documents.</p>
|
||||
<p>Please use the following link to reset your password: </p>
|
||||
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
||||
<h1 style="color: #2563eb;">Welcome to IMK Platform!</h1>
|
||||
<p>Dear ${name},</p>
|
||||
<p>Thank you for joining IMK Platform. Your account has been created successfully.</p>
|
||||
<p>You can now log in to access your documents and start collaborating with your team.</p>
|
||||
<p>If you have any questions or need assistance, please don't hesitate to contact our support team.</p>
|
||||
<div style="margin: 30px 0;">
|
||||
<a href="${process.env.FRONTEND_URL}/login"
|
||||
style="background-color: #2563eb; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px;">
|
||||
Login to Your Account
|
||||
</a>
|
||||
</div>
|
||||
<p>Best regards,<br>IMK Team</p>
|
||||
`,
|
||||
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user