spwebsite / core /models.py
geqintan's picture
update
133609a
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
class UserCredentials(BaseModel):
email: str
password: str
verification_code: Optional[str] = Field(None, alias="verificationCode") # Make verification code optional
class Config:
allow_population_by_field_name = True
populate_by_name = True
class ForgotPasswordRequest(BaseModel):
email: str
class Token(BaseModel):
access_token: str
token_type: str = "bearer"
class TokenData(BaseModel): # New model for JWT payload
user_id: Optional[str] = None
class User(BaseModel):
id: str
email: str
email_verified: bool = False
is_admin: bool = False
disabled: bool = True # Add disabled field, default to True
class ApiKeyCreateResponse(BaseModel):
api_key: str
class ApiKeyItem(BaseModel):
api_key: str
created_at: datetime
class ChangePasswordRequest(BaseModel):
new_password: str
reset_token: Optional[str] = None # For password reset flow
class ResetPasswordWithCodeRequest(BaseModel):
email: str
verification_code: str = Field(..., alias="verificationCode")
new_password: str
class Config:
allow_population_by_field_name = True
populate_by_name = True
class AdminUser(BaseModel): # New model for admin view
id: str
email: str
email_verified: bool = False
created_at: datetime
is_admin: bool = False
disabled: bool = True # Add disabled field
class UserUpdate(BaseModel): # New model for updating user info
email: Optional[str] = None
password: Optional[str] = None
email_verified: Optional[bool] = None
is_admin: Optional[bool] = None
disabled: Optional[bool] = None # Add optional disabled field