hisham-cmd commited on
Commit
d8f085f
·
verified ·
1 Parent(s): 99e0614

Upload app/schemas/auth.py

Browse files
Files changed (1) hide show
  1. app/schemas/auth.py +50 -0
app/schemas/auth.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+ from typing import Optional
3
+
4
+ from pydantic import BaseModel, EmailStr, Field
5
+
6
+
7
+ class RegisterRequest(BaseModel):
8
+ name: str = Field(..., min_length=2, max_length=255)
9
+ email: str = Field(..., max_length=255)
10
+ password: str = Field(..., min_length=6, max_length=128)
11
+ phone: Optional[str] = None
12
+
13
+
14
+ class LoginRequest(BaseModel):
15
+ email: str = Field(..., max_length=255)
16
+ password: str = Field(..., min_length=1, max_length=128)
17
+
18
+
19
+ class GoogleLoginRequest(BaseModel):
20
+ credential: str = Field(..., description="Google ID token from frontend")
21
+
22
+
23
+ class RefreshRequest(BaseModel):
24
+ refresh_token: str
25
+
26
+
27
+ class TokenResponse(BaseModel):
28
+ access_token: str
29
+ refresh_token: str
30
+ token_type: str = "bearer"
31
+
32
+
33
+ class UserResponse(BaseModel):
34
+ id: int
35
+ name: str
36
+ email: str
37
+ phone: Optional[str] = None
38
+ role: str
39
+ avatar_url: Optional[str] = None
40
+ auth_provider: str
41
+ created_at: datetime
42
+
43
+ model_config = {"from_attributes": True}
44
+
45
+
46
+ class AuthResponse(BaseModel):
47
+ isSuccess: bool
48
+ value: Optional[dict] = None
49
+ error: Optional[str] = None
50
+ statusCode: int