fix(billing): unify quota counters, fix Stripe webhooks, tier/plan sync
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 3m16s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 3m16s
This commit is contained in:
@@ -104,13 +104,14 @@ async def require_user(credentials: HTTPAuthorizationCredentials = Depends(secur
|
||||
def user_to_response(user) -> UserResponse:
|
||||
"""Convert User to UserResponse with plan limits"""
|
||||
plan_limits = PLANS[user.plan]
|
||||
tier = getattr(user, "tier", None) or user.plan
|
||||
return UserResponse(
|
||||
id=user.id,
|
||||
email=user.email,
|
||||
name=user.name,
|
||||
avatar_url=user.avatar_url,
|
||||
plan=user.plan,
|
||||
tier=user.plan,
|
||||
tier=tier,
|
||||
subscription_status=user.subscription_status,
|
||||
subscription_ends_at=getattr(user, 'subscription_ends_at', None),
|
||||
cancel_at_period_end=getattr(user, 'cancel_at_period_end', False),
|
||||
@@ -540,7 +541,7 @@ async def login_v1(request: Request):
|
||||
)
|
||||
|
||||
access_token = create_access_token(
|
||||
user.id, tier=user.plan.value, expires_delta=timedelta(minutes=15)
|
||||
user.id, tier=getattr(user, "tier", user.plan.value), expires_delta=timedelta(minutes=15)
|
||||
)
|
||||
refresh_token = create_refresh_token(user.id, expires_delta=timedelta(days=7))
|
||||
|
||||
@@ -626,7 +627,7 @@ async def google_auth_v1(body: GoogleAuthRequest):
|
||||
content={"error": "USER_CREATE_FAILED", "message": str(exc)},
|
||||
)
|
||||
|
||||
access_token = create_access_token(user.id)
|
||||
access_token = create_access_token(user.id, tier=getattr(user, "tier", "free"))
|
||||
refresh_token = create_refresh_token(user.id)
|
||||
|
||||
return JSONResponse(
|
||||
@@ -724,7 +725,7 @@ async def refresh_v1(request: Request):
|
||||
)
|
||||
|
||||
access_token = create_access_token(
|
||||
user.id, tier=user.plan.value, expires_delta=timedelta(minutes=15)
|
||||
user.id, tier=getattr(user, "tier", user.plan.value), expires_delta=timedelta(minutes=15)
|
||||
)
|
||||
new_refresh_token = create_refresh_token(user.id, expires_delta=timedelta(days=7))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user