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

Solution #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Solution #32

wants to merge 2 commits into from

Conversation

MatvijSafonov
Copy link

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.

Thank you for your hard work on this project! While your code meets many of the task requirements, there are a few critical security issues that need to be addressed before we can approve the pull request. Specifically, passwords are currently being stored without hashing, which is a significant security vulnerability. It's essential to hash passwords using a library like bcrypt to protect user data. Additionally, consider improving user feedback by differentiating error messages for expired and invalid tokens. Once these issues are resolved, your code will be in great shape! Keep up the great work! 🚀

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

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

try:
user = UserModel(
email=user_data.email,
password=user_data.password,

Choose a reason for hiding this comment

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

Security Issue: Passwords should be hashed before being stored in the database. Consider using a hashing library like bcrypt to hash the password before assigning it to the user object.

)

try:
user.password = user_data.password

Choose a reason for hiding this comment

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

Security Issue: Passwords should be hashed before being stored in the database. Ensure that the new password is hashed before being assigned to the user object.

Comment on lines +102 to +105
if not compare_digest(user_data.token, activation_token.token):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid or expired activation token."

Choose a reason for hiding this comment

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

Consideration: The error message for an invalid or expired activation token is the same. It might be beneficial to differentiate between an invalid token and an expired token for better user feedback.

Comment on lines +178 to +186

if not reset_password or user_data.token != reset_password.token:
if reset_password:
db.delete(reset_password)
db.commit()

raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid email or token."

Choose a reason for hiding this comment

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

Consideration: The error message for an invalid or expired password reset token is the same. Differentiating between these cases can provide better user feedback.

@@ -208,7 +208,7 @@ def create_movie(
return MovieDetailSchema.model_validate(movie)
except IntegrityError:
db.rollback()
raise HTTPException(status_code=400, detail=f"Invalid input data.")
raise HTTPException(status_code=400, detail="Invalid input data.")

Choose a reason for hiding this comment

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

Consideration: While handling IntegrityError, it might be useful to log the exception details for better debugging and traceability.

@@ -394,6 +394,6 @@
db.refresh(movie)
except IntegrityError:
db.rollback()
raise HTTPException(status_code=400, detail=f"Invalid input data.")
raise HTTPException(status_code=400, detail="Invalid input data.")

Choose a reason for hiding this comment

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

Consideration: While handling IntegrityError, it might be useful to log the exception details for better debugging and traceability.

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