Skip to content

Develop#262

Open
nastia7408 wants to merge 3 commits intomate-academy:masterfrom
nastia7408:develop
Open

Develop#262
nastia7408 wants to merge 3 commits intomate-academy:masterfrom
nastia7408:develop

Conversation

@nastia7408
Copy link
Copy Markdown

No description provided.

Nastia Mazur added 2 commits April 3, 2026 15:07
Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your project has a solid foundation, and the overall structure is well-organized. However, I'm requesting a few changes because some critical email functionalities are missing, which are required to complete the user workflows.

Here are the key areas to address:

  1. Send Activation Email on Registration: In src/controllers/authController.js, the activation email is not being sent after a new user is created. You need to call your mail service to send the activation link before responding with success.
  2. Notify Old Email on Change: The requirements state that when a user changes their email, a notification must be sent to their old address. This security feature is currently missing from the updateEmail function in src/controllers/authController.js.
  3. Generalize the Mail Service: Your sendActivationMail function in src/utils/mailService.js is hardcoded for one purpose. This leads to sending incorrect emails, like an 'activation' email for a password reset. Please refactor it into a more generic function that accepts parameters like the subject and body, so it can be reused for different types of notifications.

Addressing these points will ensure all user flows work as expected. Great job so far!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +42 to +48
await pool.query(query, values);

res.status(201).json({
message:
'Registration successful! ' +
'Please check your email to activate your account.',
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task requires sending an activation email after a user registers. While the user and activation token are created correctly, the call to sendActivationMail is missing here. You'll need to construct the activation link and send it to the user's email before sending the success response.


const link = `http://localhost:3000/api/activate/${activationToken}`;

await sendActivationMail(newEmail, link);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the requirements, when a user changes their email, a notification must be sent to their old email address. This is an important security measure. Currently, an activation email is sent to the new address, but there's no notification sent to the old one (user.email), which was fetched from the database earlier.

Comment on lines +16 to +29
export const sendActivationMail = async (to, link) => {
await transporter.sendMail({
from: process.env.EMAIL_USER,
to,
subject: 'Account activation on our service',
text: '',
html: `
<div>
<h1>To activate your account, please follow the link.</h1>
<a href="${link}">${link}</a>
</div>
`,
});
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is well-implemented for sending activation emails. However, its name and hardcoded subject/HTML content make it difficult to reuse for other types of emails required by the application, such as password reset links or notifying the old email address of a change. Consider making this function more generic by accepting the subject and HTML body as parameters. This would allow you to handle all email-sending requirements from a single, flexible function.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work on this update! I am happy to approve your submission. You've successfully addressed all the feedback from the previous review, resulting in a robust and complete application. The mail service is now well-designed and reusable, and all required email notifications are implemented correctly. Your project now meets all the core functional requirements. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants