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

Add account management endpoints and schemas #36

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

Conversation

Lev2098
Copy link

@Lev2098 Lev2098 commented Feb 7, 2025

Implemented user registration, activation, login, token refresh, and password reset endpoints in accounts.py. Added corresponding Pydantic schemas for request and response validation. Updated import paths and .flake8 config for better project structure and linting support.

Implemented user registration, activation, login, token refresh, and password reset endpoints in `accounts.py`. Added corresponding Pydantic schemas for request and response validation. Updated import paths and `.flake8` config for better project structure and linting support.
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 core functionality and meeting the task requirements! 🎉 While there are some areas for improvement, such as ensuring password hashing for security and refining some schema definitions, these do not critically impact the functionality. Keep up the good work and consider the feedback for future enhancements! 😊

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

detail="Invalid or expired activation token."
)
if (
utc.localize(user.activation_token.expires_at) < datetime.now(timezone.utc)

Choose a reason for hiding this comment

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

Using utc.localize() is unnecessary here since datetime.now(timezone.utc) already returns a timezone-aware datetime. Consider removing utc.localize() for clarity.

if not (
user.password_reset_token
and user.password_reset_token.token == password_reset_confirm_data.token
and utc.localize(user.password_reset_token.expires_at) > datetime.now(timezone.utc)

Choose a reason for hiding this comment

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

Using utc.localize() is unnecessary here since datetime.now(timezone.utc) already returns a timezone-aware datetime. Consider removing utc.localize() for clarity.

)

try:
user.password = password_reset_confirm_data.password

Choose a reason for hiding this comment

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

The password should be hashed before being stored in the database. Directly assigning the password without hashing is a security risk.

"token_type": "bearer"
}

except SQLAlchemyError:

Choose a reason for hiding this comment

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

Consider adding db.rollback() here to ensure the database session is rolled back in case of an exception, preventing potential data inconsistencies.



class UserActivationRequestSchema(BaseModel):
email: str

Choose a reason for hiding this comment

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

Consider using EmailStr for the email field to ensure email validation and consistency across schemas.



class MessageResponseSchema(BaseModel):
pass

Choose a reason for hiding this comment

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

The MessageResponseSchema is currently empty. Define its fields if it's intended to be used, or remove it if it's unnecessary.

Updated the Base import path for better module clarity and consistency. Reformatted table column definitions for improved readability and added `extend_existing=True` to avoid conflicts during migrations.
The `Base` import was not being used in the `movies.py` file and has been removed. This cleanup improves code readability and eliminates unnecessary imports.
Simplified and reorganized imports in `accounts.py` for clarity and removed unused imports. Fixed missing `Base` inheritance in the `movies` model to ensure proper ORM functionality.
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