mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-30 02:14:43 +08:00
Add Codex auth preservation setting
This commit is contained in:
@@ -788,9 +788,9 @@ pub fn read_codex_live_settings() -> Result<Value, AppError> {
|
||||
|
||||
/// Route a Codex live write between full auth+config or config-only.
|
||||
///
|
||||
/// Official providers with usable login material own `auth.json`; everyone
|
||||
/// else only touches `config.toml` so the user's ChatGPT login cache survives
|
||||
/// third-party switches.
|
||||
/// Official providers with usable login material own `auth.json`. Third-party
|
||||
/// providers only touch `config.toml` when the compatibility setting is enabled
|
||||
/// so the user's ChatGPT login cache survives provider switches.
|
||||
pub fn write_codex_live_for_provider(
|
||||
category: Option<&str>,
|
||||
auth: &Value,
|
||||
@@ -798,6 +798,10 @@ pub fn write_codex_live_for_provider(
|
||||
) -> Result<(), AppError> {
|
||||
if category == Some("official") && codex_auth_has_login_material(auth) {
|
||||
write_codex_live_atomic(auth, config_text)
|
||||
} else if category != Some("official")
|
||||
&& !crate::settings::preserve_codex_official_auth_on_switch()
|
||||
{
|
||||
write_codex_live_atomic(auth, config_text)
|
||||
} else {
|
||||
let live_config = prepare_codex_provider_live_config(auth, config_text.unwrap_or(""))?;
|
||||
write_codex_live_config_atomic(Some(&live_config))
|
||||
|
||||
Reference in New Issue
Block a user