|
|
@ -84,6 +84,8 @@ impl Users {
|
|
|
|
Ok(self.userid_password.iter().count())
|
|
|
|
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
|
|
|
|
/// This method will only count those local user accounts with
|
|
|
|
/// a password thus returning only real accounts on this instance.
|
|
|
|
/// a password thus returning only real accounts on this instance.
|
|
|
|
#[tracing::instrument(skip(self))]
|
|
|
|
#[tracing::instrument(skip(self))]
|
|
|
@ -92,6 +94,7 @@ impl Users {
|
|
|
|
Ok(n)
|
|
|
|
Ok(n)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Find out which user an access token belongs to.
|
|
|
|
/// Find out which user an access token belongs to.
|
|
|
|
#[tracing::instrument(skip(self, token))]
|
|
|
|
#[tracing::instrument(skip(self, token))]
|
|
|
|
pub fn find_from_token(&self, token: &str) -> Result<Option<(Box<UserId>, String)>> {
|
|
|
|
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.
|
|
|
|
/// Returns the password hash for the given user.
|
|
|
|
#[tracing::instrument(skip(self, user_id))]
|
|
|
|
#[tracing::instrument(skip(self, user_id))]
|
|
|
|
pub fn password_hash(&self, user_id: &UserId) -> Result<Option<String>> {
|
|
|
|
pub fn password_hash(&self, user_id: &UserId) -> Result<Option<String>> {
|
|
|
|