Initial commit
This commit is contained in:
41
backend/app/schemas/auth.py
Normal file
41
backend/app/schemas/auth.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Pydantic schemas for authentication requests/responses."""
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field, EmailStr
|
||||
|
||||
|
||||
class Token(BaseModel):
|
||||
"""JWT token response schema."""
|
||||
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
|
||||
|
||||
class TokenData(BaseModel):
|
||||
"""Token payload data schema."""
|
||||
|
||||
user_id: Optional[str] = None
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
"""Login request schema."""
|
||||
|
||||
username: str = Field(..., min_length=3, max_length=100)
|
||||
password: str = Field(..., min_length=1)
|
||||
|
||||
|
||||
class RegisterRequest(BaseModel):
|
||||
"""Registration request schema."""
|
||||
|
||||
username: str = Field(..., min_length=3, max_length=100)
|
||||
email: EmailStr = Field(..., description="Valid email address")
|
||||
password: str = Field(..., min_length=8, description="Password must be at least 8 characters")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"username": "johndoe",
|
||||
"email": "john@example.com",
|
||||
"password": "securepassword123"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user