mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
server: fix member_of for users with no groups
This commit is contained in:
parent
c4a63610c0
commit
c6ffaa2abf
@ -199,14 +199,27 @@ impl BackendHandler for SqlBackendHandler {
|
|||||||
user: User::from_row(rows.peek().unwrap()).unwrap(),
|
user: User::from_row(rows.peek().unwrap()).unwrap(),
|
||||||
groups: if get_groups {
|
groups: if get_groups {
|
||||||
Some(
|
Some(
|
||||||
rows.map(|row| GroupDetails {
|
rows.filter_map(|row| {
|
||||||
group_id: row.get::<GroupId, _>(&*Groups::GroupId.to_string()),
|
let display_name = row.get::<String, _>("group_display_name");
|
||||||
display_name: row.get::<String, _>("group_display_name"),
|
if display_name.is_empty() {
|
||||||
creation_date: row
|
None
|
||||||
.get::<chrono::DateTime<chrono::Utc>, _>("group_creation_date"),
|
} else {
|
||||||
uuid: row.get::<Uuid, _>("group_uuid"),
|
Some(GroupDetails {
|
||||||
|
group_id: row.get::<GroupId, _>(&*Groups::GroupId.to_string()),
|
||||||
|
display_name,
|
||||||
|
creation_date: {
|
||||||
|
debug!(
|
||||||
|
"creation_date: {}",
|
||||||
|
row.get::<String, _>("group_creation_date")
|
||||||
|
);
|
||||||
|
row.get::<chrono::DateTime<chrono::Utc>, _>(
|
||||||
|
"group_creation_date",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
uuid: row.get::<Uuid, _>("group_uuid"),
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.filter(|g| !g.display_name.is_empty())
|
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@ -675,6 +688,7 @@ mod tests {
|
|||||||
insert_user(&handler, "bob", "bob00").await;
|
insert_user(&handler, "bob", "bob00").await;
|
||||||
insert_user(&handler, "patrick", "pass").await;
|
insert_user(&handler, "patrick", "pass").await;
|
||||||
insert_user(&handler, "John", "Pa33w0rd!").await;
|
insert_user(&handler, "John", "Pa33w0rd!").await;
|
||||||
|
insert_user(&handler, "NoGroup", "Pa33w0rd!").await;
|
||||||
let group_1 = insert_group(&handler, "Best Group").await;
|
let group_1 = insert_group(&handler, "Best Group").await;
|
||||||
let group_2 = insert_group(&handler, "Worst Group").await;
|
let group_2 = insert_group(&handler, "Worst Group").await;
|
||||||
insert_membership(&handler, group_1, "bob").await;
|
insert_membership(&handler, group_1, "bob").await;
|
||||||
@ -683,7 +697,7 @@ mod tests {
|
|||||||
insert_membership(&handler, group_2, "John").await;
|
insert_membership(&handler, group_2, "John").await;
|
||||||
{
|
{
|
||||||
let users = get_user_names(&handler, None).await;
|
let users = get_user_names(&handler, None).await;
|
||||||
assert_eq!(users, vec!["bob", "john", "patrick"]);
|
assert_eq!(users, vec!["bob", "john", "nogroup", "patrick"]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let users = get_user_names(
|
let users = get_user_names(
|
||||||
@ -712,7 +726,7 @@ mod tests {
|
|||||||
)))),
|
)))),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(users, vec!["john", "patrick"]);
|
assert_eq!(users, vec!["john", "nogroup", "patrick"]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let users = handler
|
let users = handler
|
||||||
@ -737,6 +751,7 @@ mod tests {
|
|||||||
vec![
|
vec![
|
||||||
("bob".to_string(), String::new(), vec![group_1]),
|
("bob".to_string(), String::new(), vec![group_1]),
|
||||||
("john".to_string(), String::new(), vec![group_2]),
|
("john".to_string(), String::new(), vec![group_2]),
|
||||||
|
("nogroup".to_string(), String::new(), vec![]),
|
||||||
("patrick".to_string(), String::new(), vec![group_1, group_2]),
|
("patrick".to_string(), String::new(), vec![group_1, group_2]),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user