-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataModels.py
More file actions
44 lines (36 loc) · 1.38 KB
/
Copy pathdataModels.py
File metadata and controls
44 lines (36 loc) · 1.38 KB
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
# stores all pydantic models and mock data
from pydantic import BaseModel
# User model for internal representation (fetched from DB/Mock)
class User(BaseModel):
username: str
hashedPassword: str # Storing hashed password, never plain text
role: str
# Model for Login Request Body
class UserLogin(BaseModel):
username: str
password: str
# Mock Database simulating a Users table
mockUsers = {
# Password is 'admin123' hashed with Argon2
"admin":User(username="admin",hashedPassword="$argon2id$v=19$m=65536,t=3,p=4$hSkP8Py1Ht75EdnvPVLtzA$m//hpvZSvSsLvEOpJIVkr1Dc3ZN2GIOxqWjjbotXh/g",role="admin"),
# Password is 'user123' hashed with Argon2
"user":User(username="user",hashedPassword="$argon2id$v=19$m=65536,t=3,p=4$jY+I1OZ46YnY3Sj/Z6y8wQ$D1yB4OBezTTvYaeo294Zx73CR/r3Lup0kA4NssYxLXI",role="user")
}
# Model for the JWT Token response
class Token(BaseModel):
access_token: str
token_type: str
# Model for the Current User context (returned by /me)
class CurrentUser(BaseModel):
username: str
role: str
# Model for the Form Submission data
class FormDetails(BaseModel):
age: int
email: str
address: str
# Mock Database simulating stored form responses
mockFormDetails = {
"admin":FormDetails(age=45,email="admin@admin.com",address="Bengaluru,Karnataka"),
"user":FormDetails(age=18,email="user@user.com",address="Raipur,Chhattisgarh")
}