use crate::system::authentication_methods;
use crate::{arg_of, child_block};
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct LoginUser {
pub name: String,
pub class: Option<String>,
pub uid: Option<String>,
pub full_name: Option<String>,
pub authentication_methods: Vec<String>,
}
pub(super) fn parse_user(name: &str, user: &ConfigLine) -> LoginUser {
LoginUser {
name: name.to_string(),
class: arg_of(user, "class").map(str::to_string),
uid: arg_of(user, "uid").map(str::to_string),
full_name: arg_of(user, "full-name").map(str::to_string),
authentication_methods: child_block(user, "authentication")
.map(authentication_methods)
.unwrap_or_default(),
}
}