add legacy element hack for UIAA using invalid user field

see:
- e9302a9556
- https://github.com/element-hq/element-android/issues/8043
- https://github.com/element-hq/element-ios/issues/7405

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-06-06 03:43:21 -04:00
parent 3af153f5ae
commit 8428f43c78
4 changed files with 28 additions and 13 deletions

View file

@ -67,6 +67,7 @@ dev_release_log_level = [
]
element_hacks = [
"conduit-api/element_hacks",
"conduit-service/element_hacks",
]
gzip_compression = [
"conduit-api/gzip_compression",

View file

@ -17,6 +17,7 @@ crate-type = [
]
[features]
element_hacks = []
dev_release_log_level = []
release_max_log_level = [
"tracing/max_level_trace",

View file

@ -58,9 +58,22 @@ impl Service {
AuthData::Password(Password {
identifier,
password,
#[cfg(feature = "element_hacks")]
user,
..
}) => {
let UserIdentifier::UserIdOrLocalpart(username) = identifier else {
#[cfg(feature = "element_hacks")]
let username = if let Some(UserIdentifier::UserIdOrLocalpart(username)) = identifier {
username
} else if let Some(username) = user {
username
} else {
return Err(Error::BadRequest(ErrorKind::Unrecognized, "Identifier type not recognized."));
};
#[cfg(not(feature = "element_hacks"))]
let Some(UserIdentifier::UserIdOrLocalpart(username)) = identifier
else {
return Err(Error::BadRequest(ErrorKind::Unrecognized, "Identifier type not recognized."));
};