Update count users: It's now list_local_users and contains the number and the usernames
This commit is contained in:
parent
39787b41cb
commit
a69eb277d4
3 changed files with 28 additions and 12 deletions
|
@ -84,6 +84,8 @@ impl Users {
|
|||
Ok(self.userid_password.iter().count())
|
||||
}
|
||||
|
||||
/// The method is DEPRECATED and was replaced by iter_locals()
|
||||
///
|
||||
/// This method will only count those local user accounts with
|
||||
/// a password thus returning only real accounts on this instance.
|
||||
#[tracing::instrument(skip(self))]
|
||||
|
@ -92,6 +94,7 @@ impl Users {
|
|||
Ok(n)
|
||||
}
|
||||
|
||||
|
||||
/// Find out which user an access token belongs to.
|
||||
#[tracing::instrument(skip(self, token))]
|
||||
pub fn find_from_token(&self, token: &str) -> Result<Option<(Box<UserId>, String)>> {
|
||||
|
@ -131,6 +134,17 @@ impl Users {
|
|||
})
|
||||
}
|
||||
|
||||
/// Returns a vector of local usernames
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn iter_locals(&self) -> Vec<String> {
|
||||
self.userid_password.iter().filter(|(_, pw)| pw.len() > 0).map(|(username, _)| {
|
||||
match utils::string_from_bytes(&username) {
|
||||
Ok(s) => s,
|
||||
Err(e) => e.to_string()
|
||||
}
|
||||
}).collect::<Vec<String>>()
|
||||
}
|
||||
|
||||
/// Returns the password hash for the given user.
|
||||
#[tracing::instrument(skip(self, user_id))]
|
||||
pub fn password_hash(&self, user_id: &UserId) -> Result<Option<String>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue