diff --git a/schemas/login.py b/schemas/login.py new file mode 100644 index 0000000..1019472 --- /dev/null +++ b/schemas/login.py @@ -0,0 +1,40 @@ +from pydantic import BaseModel, Field, EmailStr +from typing import Optional +from datetime import datetime +from uuid import UUID + +class LoginBase(BaseModel): + email: EmailStr = Field(..., description="User's email address") + password: str = Field(..., min_length=8, description="User's password") + +class LoginCreate(LoginBase): + class Config: + schema_extra = { + "example": { + "email": "user@example.com", + "password": "securepass123" + } + } + +class Login(LoginBase): + id: UUID + user_id: UUID + login_timestamp: datetime + ip_address: Optional[str] = Field(None, description="User's IP address") + user_agent: Optional[str] = Field(None, description="User's browser agent") + success: bool = Field(default=False, description="Login attempt success status") + + class Config: + orm_mode = True + schema_extra = { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "user_id": "550e8400-e29b-41d4-a716-446655440001", + "email": "user@example.com", + "password": "securepass123", + "login_timestamp": "2023-01-01T12:00:00", + "ip_address": "192.168.1.1", + "user_agent": "Mozilla/5.0", + "success": True + } + } \ No newline at end of file