From c8b9dd310ad1b67bd851498a502bd025eac54907 Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Wed, 18 Feb 2026 06:01:11 -0500 Subject: [PATCH] validate unsandbox keys on save, reject invalid/expired --- make_post_sell/views/shop.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/make_post_sell/views/shop.py b/make_post_sell/views/shop.py index 0484751..e66a22c 100644 --- a/make_post_sell/views/shop.py +++ b/make_post_sell/views/shop.py @@ -793,15 +793,23 @@ def shop_settings(request): else: request.session.flash(("Unsandbox secret key must start with 'unsb-sk-'.", "error")) - # Backfill existing catalog when both keys are now present + # Validate keys against unsandbox API and backfill if valid if keys_changed and shop.unsandbox_public_key and shop.unsandbox_secret_key: - from ..lib.karaoke import backfill_karaoke_async - backfill_karaoke_async( - shop.id, - request.registry["dbsession_factory"], - request.app, - ) - request.session.flash(("Backfilling vocal isolation for existing catalog in background.", "success")) + from ..lib.un import validate_keys + try: + validate_keys(shop.unsandbox_public_key, shop.unsandbox_secret_key) + except Exception as e: + shop.unsandbox_public_key = None + shop.unsandbox_secret_key = None + request.session.flash((f"Unsandbox API keys are invalid or expired: {e}", "error")) + else: + from ..lib.karaoke import backfill_karaoke_async + backfill_karaoke_async( + shop.id, + request.registry["dbsession_factory"], + request.app, + ) + request.session.flash(("Backfilling vocal isolation for existing catalog in background.", "success")) # Handle maintenance settings form if form_section == "maintenance-settings":