Add Login schema
This commit is contained in:
parent
934fb912f2
commit
86c9490aac
40
schemas/login.py
Normal file
40
schemas/login.py
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user