no security
Browse files- App/Users/Schema.py +1 -0
- App/Users/UserRoutes.py +5 -5
App/Users/Schema.py
CHANGED
@@ -58,6 +58,7 @@ class RegisterUserRequest(BaseModel):
|
|
58 |
class LoginUserRequest(BaseModel):
|
59 |
phoneNumber: str = Field(..., pattern=PHONE_PATTERN)
|
60 |
password: str
|
|
|
61 |
# grant_type: Optional[str] = None
|
62 |
mac_address: Optional[str] = Field(..., pattern=MAC_PATTERN)
|
63 |
|
|
|
58 |
class LoginUserRequest(BaseModel):
|
59 |
phoneNumber: str = Field(..., pattern=PHONE_PATTERN)
|
60 |
password: str
|
61 |
+
type: str = "Normal"
|
62 |
# grant_type: Optional[str] = None
|
63 |
mac_address: Optional[str] = Field(..., pattern=MAC_PATTERN)
|
64 |
|
App/Users/UserRoutes.py
CHANGED
@@ -37,7 +37,7 @@ def create_access_token(data: dict, expires_delta: timedelta = None):
|
|
37 |
expire = datetime.utcnow() + (
|
38 |
expires_delta or timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
39 |
)
|
40 |
-
to_encode.update({"exp": expire})
|
41 |
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
42 |
|
43 |
|
@@ -90,10 +90,10 @@ async def login_user(request: LoginUserRequest):
|
|
90 |
subscription_end = (
|
91 |
subscription.expiration_time.isoformat() if subscription else None
|
92 |
)
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
access_token = create_access_token(
|
98 |
data={
|
99 |
"user_type": db_user.user_type,
|
|
|
37 |
expire = datetime.utcnow() + (
|
38 |
expires_delta or timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
39 |
)
|
40 |
+
# to_encode.update({"exp": expire})
|
41 |
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
42 |
|
43 |
|
|
|
90 |
subscription_end = (
|
91 |
subscription.expiration_time.isoformat() if subscription else None
|
92 |
)
|
93 |
+
if request.type == "Normal":
|
94 |
+
is_active = await db_user.is_active()
|
95 |
+
if is_active:
|
96 |
+
await db_user.remover_user_session()
|
97 |
access_token = create_access_token(
|
98 |
data={
|
99 |
"user_type": db_user.user_type,
|