add email login

This commit is contained in:
Emily
2024-10-10 15:49:55 +02:00
parent 0a7f2b58d0
commit 80e3b0caa9
14 changed files with 531 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ import { LIMIT_MAX_EMAIL } from './email_templates/LimitMaxEmail';
import { PURCHASE_EMAIL } from './email_templates/PurchaseEmail';
import { ANOMALY_VISITS_EVENTS_EMAIL } from './email_templates/AnomalyUsageEmail';
import { ANOMALY_DOMAIN_EMAIL } from './email_templates/AnomalyDomainEmail';
import { CONFIRM_EMAIL } from './email_templates/ConfirmEmail';
class EmailService {
@@ -150,6 +150,24 @@ class EmailService {
}
}
async sendConfirmEmail(target: string, link: string) {
try {
const sendSmtpEmail = new SendSmtpEmail();
sendSmtpEmail.subject = "Confirm your email";
sendSmtpEmail.sender = { "name": "Litlyx", "email": "no-reply@litlyx.com" };
sendSmtpEmail.to = [{ "email": target }];
sendSmtpEmail.htmlContent = CONFIRM_EMAIL
.replace(/\[CONFIRM_LINK\]/, link)
.toString();
await this.apiInstance.sendTransacEmail(sendSmtpEmail);
return true;
} catch (ex) {
console.error('ERROR SENDING EMAIL', ex);
return false;
}
}
}
const instance = new EmailService();

View File

@@ -0,0 +1,69 @@
export const CONFIRM_EMAIL = `<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Confirmation</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
.container {
background-color: #ffffff;
padding: 20px;
max-width: 600px;
margin: 0 auto;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333333;
}
p {
color: #555555;
line-height: 1.5;
}
.button {
display: inline-block;
padding: 10px 20px;
background-color: #007bff;
color: #ffffff;
text-decoration: none;
border-radius: 5px;
}
.footer {
margin-top: 20px;
font-size: 12px;
color: #777777;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h2>Confirm your email on Litlyx</h2>
<p>Hello,</p>
<p>Thank you so much for signing up on Litlyx! Please confirm your email address by clicking the button below:
</p>
<p><a href="[CONFIRM_LINK]" class="button">Confirm Email</a></p>
<p>If you didn't create an account with us, you can safely ignore this email.</p>
<p>We hope to hear from you soon!</p>
<div class="footer">
<p>&copy; 2024 Litlyx. All rights reserved.</p>
</div>
</div>
</body>
</html>`