Skip to main content

build_auth_for_edit

Function build_auth_for_edit 

Source
fn build_auth_for_edit(
    password: Option<String>,
    emails: Option<&str>,
) -> Result<AuthEdit>
Expand description

Build the auth field for a SendEditRequest.

Edit semantics differ from create:

  • (None, None) returns AuthEdit::Preserve, telling the SDK to keep the existing auth. The SDK reads the wire-format password hash and emails string off the repository row and forwards them verbatim, so a partial edit (e.g. just changing --deleteInDays) never silently strips a previously configured password or email-OTP gate. This is the fix for the auth-strip bug — the previous code emitted SendAuthType::None here, which the server treats as an overwrite.
  • (Some(p), None) / (None, Some(e)) return AuthEdit::Set { auth: _ } to overwrite to Password / Email auth.
  • (Some(_), Some(_)) is rejected (mutually exclusive).

Note: passing --password "" is not how callers strip auth on edit. To remove a previously configured password, use bw send remove-password (the legacy CLI’s dedicated subcommand), or pass AuthEdit::Set { auth: SendAuthType::None } at the SDK boundary.