settings: remove Write scope, add billing portal error handling
- Remove 'Write' scope checkbox from API key creation form — BeanFlows is a read-only data platform, write keys are meaningless to users. Scope is now always 'read' via hidden input. - Add try/except in billing.manage route so Paddle API failures (e.g. no live credentials in dev) show a user-facing flash error instead of a 500. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -201,14 +201,18 @@ async def manage():
|
||||
await flash("No active subscription found.", "error")
|
||||
return redirect(url_for("dashboard.settings"))
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(
|
||||
f"https://api.paddle.com/subscriptions/{sub['provider_subscription_id']}",
|
||||
headers={"Authorization": f"Bearer {config.PADDLE_API_KEY}"},
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
portal_url = response.json()["data"]["management_urls"]["update_payment_method"]
|
||||
except Exception:
|
||||
await flash("Could not reach the billing portal. Please try again or contact support.", "error")
|
||||
return redirect(url_for("dashboard.settings"))
|
||||
|
||||
return redirect(portal_url)
|
||||
|
||||
|
||||
|
||||
@@ -111,19 +111,7 @@
|
||||
<input type="text" id="key-name" name="name" class="form-input" placeholder="My API Key" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<span class="form-label">Scopes</span>
|
||||
<div class="flex gap-4 mt-1">
|
||||
<label class="flex items-center gap-2 text-sm text-stone-dark">
|
||||
<input type="checkbox" name="scopes" value="read" checked class="accent-copper">
|
||||
Read
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-stone-dark">
|
||||
<input type="checkbox" name="scopes" value="write" class="accent-copper">
|
||||
Write
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="scopes" value="read">
|
||||
|
||||
<button type="submit" class="btn">Create Key</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user