Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Stripe subscription syncing middleware only on specific pages #478

Merged
merged 10 commits into from
Sep 4, 2024
20 changes: 6 additions & 14 deletions app/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ def update_stripe_customer_subscription(get_response):
# One-time configuration and initialization.

def middleware(request):
stripeless_request = (
request.path.startswith(settings.STATIC_URL)
or request.path.startswith(settings.MEDIA_URL)
or request.path.startswith("/anonymous/")
or settings.SHOPIFY_WEBHOOK_PATH in request.path
or settings.SHOPIFY_WEBHOOK_PATH == request.path
or request.path.startswith("/admin/")
or request.path.startswith("/django/")
or request.path.startswith("/oauth/")
or request.path.startswith("/documents/")
or request.path.startswith("/silk/")
or request.path.startswith("/__debug__/")
or "favicon.ico" in request.path
membership_request = (
'checkout/success' in request.path
or "accounts/cancel" in request.path
or "gift/redeemed" in request.path
or "update-membership/success" in request.path
)

if not stripeless_request:
if membership_request:
# Code to be executed for each request before
# the view (and later middleware) are called.
if request.user.is_authenticated:
Expand Down
Loading