subscription
Browse files
App/Subscriptions/SubscriptionRoutes.py
CHANGED
@@ -92,20 +92,21 @@ async def get_user_subscriptions(user_id: str):
|
|
92 |
|
93 |
for subscription in subscriptions:
|
94 |
remaining_hours = await subscription.time_remaining()
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
107 |
)
|
108 |
-
)
|
109 |
|
110 |
return result
|
111 |
|
|
|
92 |
|
93 |
for subscription in subscriptions:
|
94 |
remaining_hours = await subscription.time_remaining()
|
95 |
+
if subscription.active:
|
96 |
+
result.append(
|
97 |
+
SubscriptionResponse(
|
98 |
+
id=str(subscription.id),
|
99 |
+
user_id=subscription.user_id,
|
100 |
+
plan_id=subscription.plan_id,
|
101 |
+
active=subscription.active,
|
102 |
+
duration=subscription.duration,
|
103 |
+
download_mb=subscription.download_mb,
|
104 |
+
upload_mb=subscription.upload_mb,
|
105 |
+
remaining_hours=remaining_hours,
|
106 |
+
created_time=subscription.created_time,
|
107 |
+
expiration_time=subscription.expiration_time,
|
108 |
+
)
|
109 |
)
|
|
|
110 |
|
111 |
return result
|
112 |
|
App/Users/UserRoutes.py
CHANGED
@@ -62,7 +62,13 @@ async def register_user(request: RegisterUserRequest):
|
|
62 |
async def login_user(request: LoginUserRequest):
|
63 |
db_user = await User.filter(phoneNumber=request.phoneNumber).first()
|
64 |
if db_user and db_user.verify_password(request.password):
|
65 |
-
access_token = create_access_token(
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return AccessTokenResponse(access_token=access_token, token_type="bearer")
|
67 |
raise HTTPException(
|
68 |
status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials"
|
|
|
62 |
async def login_user(request: LoginUserRequest):
|
63 |
db_user = await User.filter(phoneNumber=request.phoneNumber).first()
|
64 |
if db_user and db_user.verify_password(request.password):
|
65 |
+
access_token = create_access_token(
|
66 |
+
data={
|
67 |
+
"sub": db_user.phoneNumber,
|
68 |
+
"locked": db_user.account_locked,
|
69 |
+
"userId": db_user.id,
|
70 |
+
}
|
71 |
+
)
|
72 |
return AccessTokenResponse(access_token=access_token, token_type="bearer")
|
73 |
raise HTTPException(
|
74 |
status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials"
|