pub fn save_credential_unless_duplicate(
cred: &CredentialRef,
creds: &OAuthCredentials,
metadata: &AccountMetadata,
) -> Result<LoginPersistOutcome, String>Expand description
Login persistence: duplicate scan and write happen inside ONE locked
read-modify-write of auth.json, so two concurrent logins (or a login
racing a remove/re-login) can never create two slots owning the same
seat. A duplicate is another slot of the same provider with the same
non-empty accountId, or with an identical refresh token.
Metadata is rewritten atomically with the credential: label follows the
slot, identity is set or CLEARED (a re-login with a different seat never
keeps the old identity), addedAt is set to metadata.added_at.
A corrupt store is an error (never reset: that would wipe every other slot). With an active profile that has no own auth.json while the base store exists, the write is REFUSED: creating a profile file would hide every inherited account from that profile, and tokens are never copied.