fix(civitai): route settings writes through the options setter

post_settings wrote opts.data directly, bypassing the __setattr__ hook
that files _token keys into secrets.json; a token saved through the
endpoint landed in config.json. The setter also applies the freeze and
restricted-key guards.
This commit is contained in:
CalamitousFelicitousness
2026-09-11 23:47:03 +01:00
parent 77d368ea04
commit 1701d6aa17
+4 -4
View File
@@ -374,14 +374,14 @@ def post_settings(request: dict):
if user is None:
return JSONResponse(content={"error": "Invalid API token"}, status_code=400)
log.info(f'CivitAI token validated: user={user.get("username", "?")}')
shared.opts.data['civitai_token'] = token.strip()
shared.opts.civitai_token = token.strip()
save_subfolder_enabled = request.get('save_subfolder_enabled')
if save_subfolder_enabled is not None:
shared.opts.data['civitai_save_subfolder_enabled'] = bool(save_subfolder_enabled)
shared.opts.civitai_save_subfolder_enabled = bool(save_subfolder_enabled)
if save_subfolder is not None:
shared.opts.data['civitai_save_subfolder'] = save_subfolder
shared.opts.civitai_save_subfolder = save_subfolder
if discard_hash_mismatch is not None:
shared.opts.data['civitai_discard_hash_mismatch'] = discard_hash_mismatch
shared.opts.civitai_discard_hash_mismatch = discard_hash_mismatch
shared.opts.save()
return get_settings()