Skip to content

Conversation

@pfvatterott
Copy link
Contributor

… UpdateUser

Copy link
Contributor

@mrmauer mrmauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together! Left some comments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we don't actually need Deserialize on UpdateOrgRequest

// #[serde(rename = "require_2fa_by", skip_serializing_if = "Option::is_none")]
// pub require_2fa_by: Option<chrono::DateTime<chrono::Utc>>,
#[serde(rename = "require_2fa_by", skip_serializing_if = "Option::is_none")]
pub require_2fa_by: Option<chrono::DateTime<chrono::Utc>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we'll need a custom serializer for this. Something like


pub fn serialize_optional_datetime_to_string<S>(x: &Option<chrono::DateTime<chrono::UTC>>, s: S) -> Result<S::Ok, S::Error>
where
    S: Serializer,
{
    match x {
        Some(datetime) => s.serialize_str(&datetime.format("%Y-%m-%dT%H:%M:%s").to_string()),
        None => s.serialize_none(),
    }
}

Or something along those lines. From the docs, it seems this approach with chrono will require us to add a chrono feature to the Cargo.toml. Alternatively, we can use another DateTime type. But a raw String will put the onus of correct formatting on the caller. Either way, we should smoke test it to make sure it plays nice with the parser on the BE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Forgot to say) to then use the custom serializer

#[serde(rename = "require_2fa_by", serialize_with = "serialize_optional_datetime_to_string")]
pub require_2fa_by: Option<chrono::DateTime<chrono::Utc>>,

legacy_org_id: None,
// require_2fa_by: None,
require_2fa_by: None,
extra_domains: None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, a correction on this one...
we should instead define extra_domains as

#[serde(rename = "extra_domains", skip_serializing_if = "Option::is_none")]
pub extra_domains: Option<Vec<String>>,

to distinguish between the cases where there's no change vs setting to an empty array. Then this line stays

extra_domains: None,

Copy link
Contributor

@mrmauer mrmauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@andrew-propelauth andrew-propelauth merged commit 4dd2de0 into main Apr 4, 2025
1 check passed
@andrew-propelauth andrew-propelauth deleted the Add-require_2fa_by,-extra_domains-to-UpdateOrg.-Add-legacy_user_id-to-UpdateUser branch April 4, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants