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 #23

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

Solution #23

wants to merge 2 commits into from

Conversation

mshmygel
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.

Great job on implementing the user account-related endpoints using FastAPI! 🎉 The code is well-structured and meets the task requirements effectively. There are a few minor issues, such as ensuring the correct use of @field_validator depending on the Pydantic version and adding checks for potential None values in user_group and token_record. These improvements will enhance the robustness of your code. Keep up the excellent work! 🚀

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

detail="Invalid email or token."
)

token_record = db.query(PasswordResetTokenModel).filter_by(user_id=user.id).first()

Choose a reason for hiding this comment

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

Potential issue: token_record might be None, leading to an AttributeError when accessing token_record.expires_at. Consider checking if token_record is not None before accessing its attributes.

detail=f"A user with this email {user_data.email} already exists.",
)

user_group = db.query(UserGroupModel).filter_by(name=UserGroupEnum.USER).first()

Choose a reason for hiding this comment

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

Potential issue: user_group might be None, leading to an AttributeError when accessing user_group.id. Consider adding a check to ensure user_group is not None before proceeding.


model_config = ConfigDict(from_attributes=True)

@field_validator("email")

Choose a reason for hiding this comment

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

The decorator @field_validator is not a standard Pydantic decorator. If you are using Pydantic v1, you should use @validator. If you are using Pydantic v2, ensure that field_validator is correctly imported and used according to the new API.

def validate_email(cls, value):
return value.lower()

@field_validator("password")

Choose a reason for hiding this comment

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

Similar to the email validator, ensure that @field_validator is correctly used according to the Pydantic version you are using. If this is Pydantic v1, replace it with @validator.

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