File size: 1,767 Bytes
133609a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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