Skip to content

Conversation

@igols
Copy link

@igols igols commented Dec 27, 2025

No description provided.

Copy link

@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

This requires changes because several core features from the task description are missing. You've done a great job setting up the project structure and the initial registration flow, which is a solid foundation to build upon!

To complete the task, please focus on the following critical points:

  • Missing name Field: The user registration is incomplete. You need to add the name field to the User model in src/models/user.js and handle it in the registration controller (src/controllers/auth.controller.js).
  • Implement Redirects: After a successful login or account activation, the user should be redirected to their profile page. Currently, your controllers in src/controllers/auth.controller.js send a JSON response instead. Please implement a server-side redirect using res.redirect().
  • Missing Core Features: The application is missing several key features. You'll need to implement the routes, controllers, and services for logout, the full password reset flow, and the user profile page as outlined in the requirements.
  • Missing 404 Handler: The application must return a 404 status for any undefined routes. Please add a catch-all middleware to src/index.js to handle this.

Addressing these items will get your project aligned with the requirements. Keep up the great work!


✨ 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


const register = async (req, res) => {
try {
const { email, password } = req.body || {};

Choose a reason for hiding this comment

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

According to the task requirements, user registration should include a name field in addition to email and password. Please make sure to handle the name from the request body and save it when creating a new user.

Comment on lines 62 to 65
res.send({
message: 'Акаунт успішно активовано!',
email: user.email,
});

Choose a reason for hiding this comment

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

The requirements state that the user should be redirected to the Profile page after successful activation. Instead of sending a JSON response, you should perform a redirect, for example using res.redirect('/profile').

Comment on lines 96 to 103
res.send({
message: 'з поверненням!',
accessToken,
user: {
id: user.id,
email: user.email,
},
});

Choose a reason for hiding this comment

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

The requirements specify that the user should be redirected to the Profile page after a successful login. This implementation sends a JWT token, which is common for APIs, but it doesn't fulfill the redirect requirement. Please implement a server-side redirect.


app.get('/', (req, res) => {
res.send('index!');
});

Choose a reason for hiding this comment

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

According to the task requirements, the application must return a 404 status for all undefined pages. You should add a catch-all middleware function at the end of your route definitions (before app.listen) to handle any requests that don't match the existing routes.

req.user = userData;
next();
} catch (error) {
return res.status(401).send('ytlsqcybq njrty');

Choose a reason for hiding this comment

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

The error message sent when token verification fails appears to be scrambled text ('ytlsqcybq njrty'). It should be a clear, human-readable message, such as 'Invalid token' or 'Недійсний токен', to aid in debugging.

Comment on lines 4 to 17
const User = client.define('user', {
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
},
password: {
type: DataTypes.STRING,
allowNull: false,
},
activationToken: {
type: DataTypes.STRING,
},
});

Choose a reason for hiding this comment

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

The task requires user registration with a name, but the User model is missing this field. You should add a name property to the model definition to store the user's name.

Comment on lines +8 to +10
authRouter.post('/registration', authController.register);
authRouter.get('/activation/:activationToken', authController.activation);
authRouter.post('/login', authController.login);

Choose a reason for hiding this comment

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

This router is missing several key endpoints required by the task description. You need to add routes for logout, the password reset flow (requesting and confirming), and the profile page (viewing and updating user information).

Comment on lines 31 to 34
module.exports = {
activateSendEmail,
send,
};

Choose a reason for hiding this comment

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

This service is a good start, but it's missing functions for other required email notifications. You'll need to add methods for sending password reset emails and for notifying a user's old email address when they change it, as specified in the task requirements.

Copy link

@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

You've built a solid foundation for user registration and activation, which is great work! However, this submission requires changes because several core features are still missing and some existing functionality doesn't meet the task requirements.

Here are the main points to address:

  1. Missing Core Features: The password reset flow and the user profile page (including the ability to change name, email, and password) have not been implemented. Please add the necessary routes, controllers, and service functions to support these critical features.
  2. Incorrect Redirects: The login and logout behavior needs to be corrected.
    • In src/controllers/auth.controller.js, the login function should perform a server-side redirect to the user's profile page after a successful login, instead of returning a JSON token.
    • The logout function should redirect the user to the login page, rather than sending a 204 No Content response.

Please focus on implementing these missing pieces to complete the project. You're on the right track!


✨ 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 95 to 102
return res.status(200).send({
accessToken,
user: {
id: user.id,
name: user.name,
email: user.email,
},
});

Choose a reason for hiding this comment

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

According to the task requirements, a successful login should redirect the user to their profile page. This function currently returns a JSON response with a token instead. Please implement a server-side redirect here, similar to how you've done it in the activation function.


const logout = async (req, res) => {
try {
res.status(204).send();

Choose a reason for hiding this comment

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

The requirements state that after logging out, the user should be redirected to the login page. This implementation sends a 204 No Content response, but it should perform a redirect.

Comment on lines 23 to 25
if (!userData) {
return res.status(401).send('email не авторизовано');
}

Choose a reason for hiding this comment

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

This check for !userData is redundant. If jwt.verify fails to validate the token (e.g., it's invalid or expired), it will throw an error, which is caught by the catch block below. If it succeeds, userData will always be a truthy object (the decoded payload). You can safely remove this if block.

authRouter.post('/registration', authController.register);
authRouter.get('/activation/:activationToken', authController.activation);
authRouter.post('/login', authController.login);
authRouter.post('/logout', authMiddleware, authController.logout);

Choose a reason for hiding this comment

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

This router is a good start, but it's missing several required endpoints. According to the task description, you also need to implement routes for the full password reset flow and for managing the user profile (e.g., changing name, email, and password).

Comment on lines 31 to 34
module.exports = {
activateSendEmail,
send,
};

Choose a reason for hiding this comment

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

This service is a good start, but it only handles activation emails. According to the task requirements, you will also need to send emails for password resets and to notify users when their email address has been changed. Consider adding more functions here to support those features.

Copy link

@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

I am approving this submission as an educational override to help you progress, but there are a few important validation checks you'll need to add. Great job on the overall structure of the application! The routing, middleware, and services are all well-implemented.

The main area for improvement is in src/controllers/auth.controller.js. The task requires you to add confirmation checks for sensitive operations. Specifically:

  • When resetting a password, you need to verify that the password and confirmation fields match.
  • The same password confirmation check is needed when a user changes their password on their profile page.
  • When a user changes their email, you should also add a confirmation field to prevent typos.

Adding these checks will make the application more secure and user-friendly. 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


const resetPasswordConfirm = async (req, res) => {
try {
const { token, password } = req.body;

Choose a reason for hiding this comment

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

According to the task requirements, the password reset confirmation should include both a password and a confirmation field. You need to add a check to ensure these two fields are equal before proceeding with the password update.

return res.status(400).send('Невірний старий пароль');
}

if (newPassword) {

Choose a reason for hiding this comment

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

The requirements for changing a password on the profile page state that it needs a new password and a confirmation field that must match. Please add this validation check here.

user.password = await bcrypt.hash(newPassword, 10);
}

if (email && email !== user.email) {

Choose a reason for hiding this comment

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

The task requires the user to "confirm the new email". This usually means the request should contain two fields, for example email and emailConfirmation, and you should verify they match before updating the user's email address. This validation is currently missing.

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