Skip to content

Conversation

Saahi30
Copy link
Collaborator

@Saahi30 Saahi30 commented Jun 5, 2025

Here’s a complete PR description you can use for your remove-password-hash branch, including the SQL migration:

📝 Description

This pull request removes the password_hash column from the public users table in both the backend code and the database schema. Passwords are securely managed by Supabase Auth in its private auth.users table, so storing a password hash in the public profile table is unnecessary and could be a security risk.

🔧 Changes Made

  • Removed the password_hash field from the SQLAlchemy User model.
  • Removed the password_hash field from the Pydantic UserCreate schema.
  • Removed the password_hash field from the /users/ creation route.
  • Updated all relevant code to no longer reference or insert password_hash.
  • Added SQL migration instructions to drop the column from the database.

🛠️ SQL Migration

To remove the password_hash column from your existing database, run the following SQL in your Supabase SQL editor or psql:

ALTER TABLE public.users DROP COLUMN IF EXISTS password_hash;

✅ Checklist

  • [✅ ] I have read the contributing guidelines.

Summary by CodeRabbit

  • Refactor
    • Removed storage and handling of password hashes from user-related database tables and user creation forms.
    • Updated user creation process to align with external password management by Supabase Auth.

Copy link
Contributor

coderabbitai bot commented Jun 5, 2025

Walkthrough

The changes remove the handling and storage of password hashes from the backend system. The password_hash field is eliminated from the database model, user creation schema, and the user creation route. Password management is now delegated to Supabase Auth, and password hashes are no longer processed or stored by the application.

Changes

File(s) Change Summary
Backend/app/models/models.py Removed password_hash column from the User database model.
Backend/app/routes/post.py Omitted password_hash from the user creation payload sent to Supabase.
Backend/app/schemas/schema.py Removed (commented out) password_hash field from the UserCreate Pydantic schema.
Backend/app/db/seed.py Removed password assignment and password field from user seed data creation.

Poem

A hop and a skip, the hashes are gone,
Supabase Auth now carries us on.
No more secrets tucked away,
In our models, clear as day.
With lighter code, we leap ahead—
Let bunnies rest, no passwords to dread!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1150330 and cc13afb.

📒 Files selected for processing (1)
  • Backend/app/db/seed.py (0 hunks)
💤 Files with no reviewable changes (1)
  • Backend/app/db/seed.py
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @Saahi30, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello team, gemini-code-assist here to provide a summary of this pull request. This PR, authored by Saahi30, aims to remove the password_hash column from the public users table and all associated backend code. The rationale, as stated in the description, is that password management is handled securely by Supabase Auth in its private tables, making storage of the hash in the public profile table redundant and potentially risky. The changes involve updating the SQLAlchemy model, the Pydantic schema for user creation, and the user creation route logic to no longer include or reference password_hash. A necessary SQL migration is also noted to drop the column from the database.

Highlights

  • Database Schema Update: Removes the password_hash column definition from the SQLAlchemy User model, reflecting the change in the public users table schema.
  • API Schema Update: Removes the password_hash field from the UserCreate Pydantic schema, preventing clients from sending password hashes during user creation via this endpoint.
  • User Creation Logic Update: Modifies the user creation route (/users/) to no longer attempt to insert a password_hash value into the database.
  • Database Migration Required: Notes that a SQL migration is required to drop the password_hash column from the existing public.users table in the database.

Changelog

  • Backend/app/models/models.py
    • Removed the password_hash column definition from the User SQLAlchemy model (line 30).
  • Backend/app/routes/post.py
    • Removed the password_hash key and value from the dictionary used to create a new user entry in the database within the create_user route (line 47).
  • Backend/app/schemas/schema.py
    • Removed the password_hash field from the UserCreate Pydantic schema and added a comment indicating its removal (line 8).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Password hash removed,
Supabase handles the rest,
Security improved.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively removes the password_hash field from the user model, schema, and creation route, aligning with the strategy of managing passwords solely through Supabase Auth. This is a good move for security and simplification.

The changes are clear, concise, and directly address the issue described. The inclusion of the SQL migration command in the PR description is particularly helpful and demonstrates thoroughness. Well done!

Summary of Findings

  • Code Cleanliness in Schema: In Backend/app/schemas/schema.py, the password_hash: str line is commented out with an explanatory comment. While the comment is good, for a permanent removal as indicated by the PR's intent, deleting the line entirely would be slightly cleaner. This is a minor point and doesn't affect functionality. (Severity: low - not commented on directly due to review settings).

Merge Readiness

The changes look good and directly achieve the stated goal of removing the redundant password_hash. The PR description is clear and includes the necessary database migration step. Based on this review, the code appears ready for merging. As always, ensure any CI checks pass and consider if any other team members need to review before merging. I am unable to approve the pull request myself, but I see no blockers from my side.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5690da4 and 1150330.

📒 Files selected for processing (3)
  • Backend/app/models/models.py (0 hunks)
  • Backend/app/routes/post.py (0 hunks)
  • Backend/app/schemas/schema.py (1 hunks)
💤 Files with no reviewable changes (2)
  • Backend/app/routes/post.py
  • Backend/app/models/models.py
🔇 Additional comments (1)
Backend/app/schemas/schema.py (1)

8-8: Good security improvement!

Removing the password_hash field from the UserCreate schema is the correct approach when delegating authentication to Supabase Auth. This prevents password hashes from being processed by the application layer.

Comment on lines 5 to 11
class UserCreate(BaseModel):
username: str
email: str
password_hash: str
# password_hash: str # Removed: managed by Supabase Auth
role: str
profile_image: Optional[str] = None
bio: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify consistency across the codebase.

Ensure that all code referencing the password_hash field in UserCreate has been updated to prevent runtime errors.


🏁 Script executed:

#!/bin/bash
# Description: Verify that no code still references password_hash in UserCreate or related user creation logic
# Expected: No remaining references to password_hash in user creation code

echo "=== Searching for password_hash references in Python files ==="
rg -A 3 -B 3 "password_hash" --type py

echo -e "\n=== Searching for UserCreate usage that might expect password_hash ==="
rg -A 5 -B 5 "UserCreate" --type py

echo -e "\n=== Checking for any remaining password-related fields in schemas ==="
rg -A 3 -B 3 "password" Backend/app/schemas/ --type py

Length of output: 3760


Fix seeding logic that still sets password_hash

The seeder in Backend/app/db/seed.py still assigns a plain‐text password to password_hash, but passwords are now managed by Supabase Auth. Update or remove this mapping to avoid runtime errors:

• Location: Backend/app/db/seed.py

-    password_hash=user_data["password"],  # Using plain password directly
+    # Remove direct password_hash assignment. 
+    # Instead, use Supabase Auth (e.g., supabase.auth.admin.create_user) 
+    # to provision users with passwords, or omit password fields here.

• Ensure any tests or downstream code expecting password_hash are updated to use Supabase’s user/session objects instead.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class UserCreate(BaseModel):
username: str
email: str
password_hash: str
# password_hash: str # Removed: managed by Supabase Auth
role: str
profile_image: Optional[str] = None
bio: Optional[str] = None
for user_data in users:
user = User(
username=user_data["username"],
email=user_data["email"],
- password_hash=user_data["password"], # Using plain password directly
+ # Remove direct password_hash assignment.
+ # Instead, use Supabase Auth (e.g., supabase.auth.admin.create_user)
+ # to provision users with passwords, or omit password fields here.
role=user_data["role"],
profile_image=user_data.get("profile_image"),
bio=user_data.get("bio"),
)
db.session.add(user)
db.session.commit()
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 5-5: Too few public methods (0/2)

(R0903)

🤖 Prompt for AI Agents
In Backend/app/db/seed.py, update the seeding logic that still assigns a
plain-text password to the password_hash field, which is no longer part of
UserCreate since password management is handled by Supabase Auth. Remove or
refactor any code that sets password_hash during user creation to prevent
runtime errors. Additionally, review and update any tests or downstream code
that expect password_hash to instead use Supabase’s user or session objects for
authentication data.

@chandansgowda chandansgowda changed the title Remove password_hash from users model, schema, and route (cuz it is managed by supabase auth) Remove password_hash from users model, schema, and route (now managed by supabase auth) Jun 14, 2025
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.

1 participant