from datetime import datetime

from pydantic import BaseModel, EmailStr


class UserCreate(BaseModel):
    email: EmailStr
    password: str
    name: str
    turnstile_token: str | None = None


class UserResponse(BaseModel):
    id: int
    email: str
    name: str
    role: str
    is_unthrottled: int = 0
    created_at: datetime

    class Config:
        from_attributes = True


class Token(BaseModel):
    access_token: str
    token_type: str = "bearer"


class LoginRequest(BaseModel):
    email: EmailStr
    password: str
    turnstile_token: str | None = None


class UserUpdateRole(BaseModel):
    role: str


class UserUpdateMe(BaseModel):
    name: str | None = None
    current_password: str | None = None
    new_password: str | None = None


class ForgotPasswordRequest(BaseModel):
    email: EmailStr


class ResetPasswordRequest(BaseModel):
    token: str
    new_password: str
