-
Notifications
You must be signed in to change notification settings - Fork 1
Add live artifact editor and demo login #2
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,12 @@ class GoogleAuthRequest(BaseModel): | |
| id_token: str | ||
|
|
||
|
|
||
| class DevLoginRequest(BaseModel): | ||
| """Request body for dummy/demo login (dev & demos only).""" | ||
| name: Optional[str] = None | ||
| email: Optional[str] = None | ||
|
Comment on lines
+16
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Inspect declared Pydantic version so the validation API can be matched to the installed major version.
fd -i '^(pyproject\.toml|requirements.*\.txt|poetry\.lock|Pipfile)$' \
-x sh -c 'echo "--- $1"; rg -n "pydantic|email-validator" "$1" || true' sh {}Repository: Aniket25042003/CortexLab Length of output: 144 🏁 Script executed: rg -n "email-validator" --type txt --type tomlRepository: Aniket25042003/CortexLab Length of output: 50 🏁 Script executed: fd -i 'user.py' -path '*/models/*' -x cat -n {}Repository: Aniket25042003/CortexLab Length of output: 236 🏁 Script executed: rg -n "demo:" --type pyRepository: Aniket25042003/CortexLab Length of output: 127 🏁 Script executed: rg -n "DevLoginRequest" --type py -A 5Repository: Aniket25042003/CortexLab Length of output: 1757 🏁 Script executed: rg -n "email-validator" backend/Repository: Aniket25042003/CortexLab Length of output: 50 🏁 Script executed: fd -i 'user.py' -path '*/models/*' -x head -100 {}Repository: Aniket25042003/CortexLab Length of output: 236 🏁 Script executed: sed -n '140,170p' backend/app/api/auth.pyRepository: Aniket25042003/CortexLab Length of output: 1117 🏁 Script executed: find backend -name "*.py" -path "*/models/*" | head -5Repository: Aniket25042003/CortexLab Length of output: 231 🏁 Script executed: rg -n "class User" backend/ --type py -A 10Repository: Aniket25042003/CortexLab Length of output: 1230 🏁 Script executed: cat backend/requirements.txtRepository: Aniket25042003/CortexLab Length of output: 753 🏁 Script executed: cat -n backend/app/models/user.pyRepository: Aniket25042003/CortexLab Length of output: 1698 Validate demo login input at the schema boundary.
🛡️ Proposed validation-from pydantic import BaseModel
+from pydantic import BaseModel, Field
from typing import Optional
class DevLoginRequest(BaseModel):
"""Request body for dummy/demo login (dev & demos only)."""
- name: Optional[str] = None
- email: Optional[str] = None
+ name: Optional[str] = Field(default=None, max_length=255)
+ email: Optional[str] = Field(default=None, max_length=250)🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| class UserResponse(BaseModel): | ||
| """User data response.""" | ||
| id: str | ||
|
|
||
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.
Handle demo email collisions before inserting.
The route looks up only by
google_id, then insertsemail. If an unauthenticated caller supplies an email already used by another account, the uniqueUser.emailconstraint will fail and return a 500. Reject non-demo-domain emails or explicitly detect collisions beforedb.add().🛡️ Proposed collision guard
email = (request.email or "demo@cortexlab.local").strip().lower() name = (request.name or "Demo Researcher").strip() or "Demo Researcher" + + if not email.endswith("@cortexlab.local"): + raise HTTPException(status_code=400, detail="Demo login requires a demo email address") + # Stable synthetic google_id so the same demo email always maps to the same user google_id = f"demo:{email}" result = await db.execute(select(User).where(User.google_id == google_id)) user = result.scalar_one_or_none() if not user: + existing_email_result = await db.execute(select(User).where(User.email == email)) + existing_email_user = existing_email_result.scalar_one_or_none() + if existing_email_user: + raise HTTPException(status_code=409, detail="Demo email is already in use") + user = User( google_id=google_id, email=email, name=name, avatar_url=None,📝 Committable suggestion
🤖 Prompt for AI Agents