validate unsandbox keys on save, reject invalid/expired
This commit is contained in:
parent
be40ab432b
commit
c8b9dd310a
1 changed files with 16 additions and 8 deletions
|
|
@ -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":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue