Mbonea commited on
Commit
84b44a7
·
1 Parent(s): dddd52a

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
- result.append(
96
- SubscriptionResponse(
97
- id=str(subscription.id),
98
- user_id=subscription.user_id,
99
- plan_id=subscription.plan_id,
100
- active=subscription.active,
101
- duration=subscription.duration,
102
- download_mb=subscription.download_mb,
103
- upload_mb=subscription.upload_mb,
104
- remaining_hours=remaining_hours,
105
- created_time=subscription.created_time,
106
- expiration_time=subscription.expiration_time,
 
 
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(data={"sub": db_user.phoneNumber})
 
 
 
 
 
 
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"