2a9ebe24: Implement auth endpoints (register/login/JWT) with SQLAlchemy

This commit is contained in:
OpenClaw Agent
2026-04-16 12:51:02 +00:00
parent ef5b32143a
commit 135d4111bb
12 changed files with 417 additions and 8 deletions

40
app/schemas/auth.py Normal file
View File

@@ -0,0 +1,40 @@
"""Authentication Pydantic schemas."""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, ConfigDict, EmailStr, Field
class UserRegister(BaseModel):
"""Request model for user registration."""
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr
password: str = Field(..., min_length=6)
class UserLogin(BaseModel):
"""Request model for user login."""
username: str
password: str
class Token(BaseModel):
"""Response model for JWT token."""
access_token: str
token_type: str = "bearer"
class UserResponse(BaseModel):
"""Response model for user data."""
id: int
username: str
email: str
avatar_url: Optional[str] = "/static/default-avatar.png"
bio: Optional[str] = ""
created_at: datetime
model_config = ConfigDict(from_attributes=True)