mirror of
				https://github.com/fastapi-users/fastapi-users.git
				synced 2025-11-01 01:48:46 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			960 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			960 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from typing import Generic, Optional, Protocol, TypeVar
 | |
| 
 | |
| ID = TypeVar("ID")
 | |
| 
 | |
| 
 | |
| class UserProtocol(Protocol[ID]):
 | |
|     """User protocol that ORM model should follow."""
 | |
| 
 | |
|     id: ID
 | |
|     email: str
 | |
|     hashed_password: str
 | |
|     is_active: bool
 | |
|     is_superuser: bool
 | |
|     is_verified: bool
 | |
| 
 | |
| 
 | |
| class OAuthAccountProtocol(Protocol[ID]):
 | |
|     """OAuth account protocol that ORM model should follow."""
 | |
| 
 | |
|     id: ID
 | |
|     oauth_name: str
 | |
|     access_token: str
 | |
|     expires_at: Optional[int]
 | |
|     refresh_token: Optional[str]
 | |
|     account_id: str
 | |
|     account_email: str
 | |
| 
 | |
| 
 | |
| UP = TypeVar("UP", bound=UserProtocol)
 | |
| OAP = TypeVar("OAP", bound=OAuthAccountProtocol)
 | |
| 
 | |
| 
 | |
| class UserOAuthProtocol(UserProtocol[ID], Generic[ID, OAP]):
 | |
|     """User protocol including a list of OAuth accounts."""
 | |
| 
 | |
|     id: ID
 | |
|     email: str
 | |
|     hashed_password: str
 | |
|     is_active: bool
 | |
|     is_superuser: bool
 | |
|     is_verified: bool
 | |
|     oauth_accounts: list[OAP]
 | |
| 
 | |
| 
 | |
| UOAP = TypeVar("UOAP", bound=UserOAuthProtocol)
 | 
