Skip to content

Master - #3

Merged
sajeerrr merged 2 commits into
mainfrom
master
Jul 28, 2026
Merged

Master#3
sajeerrr merged 2 commits into
mainfrom
master

Conversation

@sajeerrr

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 28, 2026 08:02
@sajeerrr
sajeerrr merged commit 563f181 into main Jul 28, 2026
1 of 2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces initial user authentication/session support to the StudyMate FastAPI app, and begins wiring user identity into the persistence layer.

Changes:

  • Added /login and /logout endpoints that create/delete server-side sessions and set a session_id cookie.
  • Added/extended SQLAlchemy models to include User, UserSession, and user foreign keys on existing records.
  • Tightened schema validation for user login fields by using EmailStr.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
schemas.py Adds EmailStr typing and organizes request schemas for chat/quiz/user flows.
main.py Introduces login/logout routes with cookie-based session handling and imports new models/schemas.
db/models.py Adds User/UserSession models and adds user foreign keys to existing models.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.py
Comment on lines +74 to +79
# Verify password
if user.password != request.password:
raise HTTPException(
status_code=401,
detail="Invalid email or password"
)
Comment thread main.py
Comment on lines +94 to +99
response.set_cookie(
key="session_id",
value=session_id,
httponly=True,
samesite="lax"
)
Comment thread main.py
@app.post("/logout")
def logout(
response: Response,
session_id: str = Cookie(None),
Comment thread main.py
Comment on lines +56 to +61
@app.post("/login")
def login(
request: UserLogin,
response: Response,
db: Session = Depends(get_db)
):
Comment thread db/models.py
Comment on lines 9 to 11
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users.id")) # NEW
topic = Column(String)
Comment thread db/models.py
Comment on lines +30 to +33
id = Column(Integer, primary_key=True, index=True)
session_id = Column(String, unique=True, index=True)
user_id = Column(Integer, ForeignKey("users.id"))
created_at = Column(DateTime, default=datetime.utcnow)
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