Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/refactor account activation mailing #1224

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-to-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
mapped_name=$branch_name
fi
mapped_name_upper=$(echo "$mapped_name" | tr '[:lower:]' '[:upper:]')
echo "Environment name used: $mapped_name"
echo "Environment name found matching branch name: Using the environment name"
echo "##[set-output name=env_name;]$mapped_name"
echo "##[set-output name=env_name_upper;]$mapped_name_upper"
id: set_env
env:
PILOT: ${{ secrets.PILOT }}
PILOT: ${{ vars.PILOT }}

wait_for_image_push:
name: Wait for Docker images to be pushed
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ jobs:
mapped_name=$branch_name
fi
mapped_name_upper=$(echo "$mapped_name" | tr '[:lower:]' '[:upper:]')
echo "Environment name used: $mapped_name"
echo "Environment name found matching branch name: Using the environment name"
echo "##[set-output name=env_name;]$mapped_name"
echo "##[set-output name=env_name_upper;]$mapped_name_upper"
id: set_env
env:
PILOT: ${{ secrets.PILOT }}
PILOT: ${{ vars.PILOT }}

wait_for_tests:
name: Wait for tests to finish running
Expand Down
55 changes: 41 additions & 14 deletions api/src/modules/authentication/password-mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,50 @@ export class PasswordMailService {

async sendUserActivationEmail(email: string, token: string): Promise<void> {
const htmlContent: string = `
<h1>Welcome to Landgriffon!</h1>
<p>An account has been created for you by an administrator. As this is your first time logging in, we request you create a new password for your account.</p>
<br/>
<p>To get started, please click on the link below:</p>
<p><a href="${this.passwordActivationUrl}/${token}">Secure Password Setup Link</a></p>
<br/>
<p>This link will take you to our app where you can create your new password. For security reasons, this link will expire after 24 hours.</p>
<p>Please remember that a strong password includes a mix of letters, numbers, and special characters. Never share your password with anyone, even if they claim to be from Landgriffon.</p>
<p>Our team will never ask you for your password in an email, over the phone, or on any social media platform.</p>
<p>Thank you for choosing Landgriffon. We are committed to providing you with a secure and seamless experience.</p>
<br/>
<p>If you have any questions or need further assistance, please don't hesitate to contact us.</p>
<p>Best regards.</p>`;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Landgriffon</title>
</head>
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
<h1 style="color: #2c3e50;">Welcome to Landgriffon!</h1>

<p>Hi there,</p>

<p>An account has been created for you. To get started, please set it up by clicking the link below:</p>

<p>
<a href="${this.passwordActivationUrl}/${token}" style="background-color: #3498db; color: #ffffff; padding: 10px 15px; text-decoration: none; border-radius: 5px;">
Set Up Your Account
</a>
</p>

<p>This link will expire in 24 hours for security purposes.</p>

<p>To ensure a secure account, we recommend using a password with a mix of letters, numbers, and special characters.</p>

<p>If you didn't request this, please ignore this email.</p>

<p>For any assistance, feel free to reach out to our support team at
<a href="mailto:[email protected]">[email protected]</a>.
</p>

<p>Best regards,<br/>The Landgriffon Team</p>

<hr style="border: none; border-top: 1px solid #ccc;" />

<p style="font-size: 12px; color: #777;">
If you have received this email by mistake, please disregard it. You are receiving this email as part of your Landgriffon account registration.
</p>
</body>
</html>
`;

await this.emailService.sendMail({
to: email,
subject: 'Welcome to Landgriffon - Please Set Up Your Password',
subject: 'Welcome to Landgriffon - Set up your Account',
html: htmlContent,
});
}
Expand Down
16 changes: 14 additions & 2 deletions api/src/modules/notifications/email/sendgrid.email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as sgMail from '@sendgrid/mail';
import * as config from 'config';
import { MailDataRequired } from '@sendgrid/helpers/classes/mail';

const SENDER_MAIL_ADDRESS: string = '[email protected]';
// Can't check rn, but this address might be authenticated in Sendgrid as it is used in the mkt site
const SENDER_MAIL_ADDRESS: string = '[email protected]';

@Injectable()
export class SendgridEmailService implements IEmailService {
Expand All @@ -28,7 +29,18 @@ export class SendgridEmailService implements IEmailService {
}

async sendMail(mail: SendMailDTO): Promise<any> {
const msg: MailDataRequired = { ...mail, from: SENDER_MAIL_ADDRESS };
const msg: MailDataRequired = {
...mail,
from: SENDER_MAIL_ADDRESS,
trackingSettings: {
clickTracking: {
enable: false,
},
openTracking: {
enable: false,
},
},
};
try {
return sgMail.send(msg);
} catch (e) {
Expand Down