diff --git a/crates/ruma-client-api/src/uiaa.rs b/crates/ruma-client-api/src/uiaa.rs index aebc8c51..50814c12 100644 --- a/crates/ruma-client-api/src/uiaa.rs +++ b/crates/ruma-client-api/src/uiaa.rs @@ -149,6 +149,7 @@ impl AuthData { identifier: x.identifier.clone(), password: x.password.clone(), session: None, + user: None, })), Self::ReCaptcha(x) => { Cow::Owned(serialize(ReCaptcha { response: x.response.clone(), session: None })) @@ -266,28 +267,36 @@ pub enum AuthType { #[serde(tag = "type", rename = "m.login.password")] pub struct Password { /// One of the user's identifiers. - pub identifier: UserIdentifier, + #[serde(skip_serializing_if = "Option::is_none")] + pub identifier: Option, /// The plaintext password. pub password: String, /// The value of the session key given by the homeserver, if any. pub session: Option, + + /// Username for the user. (Legacy Element Android/iOS hack, do not use!) + /// + /// See + #[serde(skip_serializing_if = "Option::is_none")] + pub user: Option, } impl Password { /// Creates a new `Password` with the given identifier and password. pub fn new(identifier: UserIdentifier, password: String) -> Self { - Self { identifier, password, session: None } + Self { identifier: Some(identifier), password, session: None, user: None } } } impl fmt::Debug for Password { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let Self { identifier, password: _, session } = self; + let Self { identifier, password: _, session, user } = self; f.debug_struct("Password") .field("identifier", identifier) .field("session", session) + .field("user", user) .finish_non_exhaustive() } }