-
Notifications
You must be signed in to change notification settings - Fork 48
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
base: main
Are you sure you want to change the base?
Solution #23
Conversation
There was a problem hiding this 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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
.
No description provided.