Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Backend/app/db/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ async def seed_db():
"id": "aabb1fd8-ba93-4e8c-976e-35e5c40b809c",
"username": "creator1",
"email": "[email protected]",
"password": "password123",
"role": "creator",
"bio": "Lifestyle and travel content creator",
},
{
"id": "6dbfcdd5-795f-49c1-8f7a-a5538b8c6f6f",
"username": "brand1",
"email": "[email protected]",
"password": "password123",
"role": "brand",
"bio": "Sustainable fashion brand looking for influencers",
},
Expand All @@ -40,9 +38,6 @@ async def seed_db():
id=user_data["id"],
username=user_data["username"],
email=user_data["email"],
password_hash=user_data[
"password"
], # Using plain password directly
role=user_data["role"],
bio=user_data["bio"],
)
Comment on lines 38 to 43

Choose a reason for hiding this comment

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

medium

Since you're removing the password, it might be worth adding a comment here explaining why these users don't have passwords. This will help future developers understand the context.

Suggested change
id=user_data["id"],
username=user_data["username"],
email=user_data["email"],
password_hash=user_data[
"password"
], # Using plain password directly
role=user_data["role"],
bio=user_data["bio"],
)
id=user_data["id"],
username=user_data["username"],
email=user_data["email"],
role=user_data["role"],
bio=user_data["bio"], # Password managed by Supabase Auth

Comment on lines 38 to 43

Choose a reason for hiding this comment

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

medium

Consider adding a try-except block around the user creation and seeding process to catch any potential exceptions during database operations. This will improve the robustness of the seeding process.

                try:
                    user = User(
                        id=user_data["id"],
                        username=user_data["username"],
                        email=user_data["email"],
                        role=user_data["role"],
                        bio=user_data["bio"],
                    )
                    session.add(user)
                    print(f"Created user: {user_data['email']}")
                except Exception as e:
                    print(f"Error creating user {user_data['email']}: {e}")
                    await session.rollback() # Rollback in case of error

Expand Down
1 change: 0 additions & 1 deletion Backend/app/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class User(Base):
id = Column(String, primary_key=True, default=generate_uuid)
username = Column(String, unique=True, nullable=False)
email = Column(String, unique=True, nullable=False)
password_hash = Column(Text, nullable=False)
role = Column(String, nullable=False) # 'creator' or 'brand'
profile_image = Column(Text, nullable=True)
bio = Column(Text, nullable=True)
Expand Down
1 change: 0 additions & 1 deletion Backend/app/routes/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ async def create_user(user: UserCreate):
"id": user_id,
"username": user.username,
"email": user.email,
"password_hash": user.password_hash,
"role": user.role,
"profile_image": user.profile_image,
"bio": user.bio,
Expand Down
2 changes: 1 addition & 1 deletion Backend/app/schemas/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class UserCreate(BaseModel):
username: str
email: str
password_hash: str
# password_hash: str # Removed: managed by Supabase Auth
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 consistent removal of password handling across the codebase.

The architectural decision to delegate authentication to Supabase Auth is sound, and the implementation approach of commenting out the field with a clear explanation is good practice. However, ensure this breaking change is handled consistently across all related code.

Run the following script to verify that password hash handling has been consistently removed:


🏁 Script executed:

#!/bin/bash
# Description: Verify that password_hash references have been consistently removed or updated
# Expected: Should find no active password_hash usage in user creation/management code

echo "Checking for remaining password_hash references in active code:"
rg "password_hash" --type py -A 2 -B 2

echo -e "\nChecking user creation endpoints for password handling:"
rg -A 10 -B 5 "UserCreate|user.*create" Backend/app/routes/

echo -e "\nChecking database models for password fields:"
rg -A 5 -B 5 "password" Backend/app/models/

echo -e "\nChecking if Supabase Auth integration is properly implemented:"
rg -A 5 "supabase.*auth|auth.*supabase" Backend/app/

Length of output: 2857


Let’s verify that the Supabase Auth client is actually being initialized and that any auth methods (e.g. sign-up/sign-in) are in use:


🏁 Script executed:

#!/bin/bash
# Search for Supabase client initialization
echo "Locating Supabase client instantiation:"
rg -n "create_client" -A2 -B2 Backend/app/

echo -e "\nChecking for any supabase.auth API usage (sign_up, sign_in, user):"
rg -nE "supabase\.auth\.(sign_(up|in)|user)" -A2 -B2 Backend/app/

Length of output: 999


Ensure Supabase Auth sign-up/sign-in is actually invoked

While password_hash has been removed consistently, I didn’t find any calls to the Supabase Auth API (e.g. supabase.auth.sign_up, sign_in, or fetching supabase.auth.user)—only direct inserts into the users table. Without invoking Supabase Auth methods, users won’t be registered or authenticated correctly.

• Backend/app/routes/post.py – Supabase client is initialized at line 25 (create_client), but no supabase.auth.* calls follow.
• No occurrences of supabase.auth.sign_up or supabase.auth.sign_in in the codebase.

Please implement or verify that your user registration and login flows call the appropriate Supabase Auth methods instead of only performing DB inserts.

🤖 Prompt for AI Agents
In Backend/app/schemas/schema.py at line 8, the password_hash field has been
removed as authentication is delegated to Supabase Auth. However, across the
codebase, especially in Backend/app/routes/post.py around line 25 where the
Supabase client is initialized, you need to replace direct database inserts for
user creation and login with calls to Supabase Auth methods such as
supabase.auth.sign_up and supabase.auth.sign_in. Review and update the user
registration and login flows to invoke these Supabase Auth APIs to ensure proper
user authentication and registration instead of only inserting users directly
into the database.

role: str
profile_image: Optional[str] = None
bio: Optional[str] = None
Expand Down