Expose user manager in request
This commit is contained in:
parent
e83f2ca109
commit
47c6fae79f
|
@ -126,6 +126,14 @@ impl Request {
|
|||
{
|
||||
Ok(self.manager.get_user(self.certificate())?)
|
||||
}
|
||||
|
||||
#[cfg(feature="user_management")]
|
||||
/// Expose the server's UserManager
|
||||
///
|
||||
/// Can be used to query users, or directly access the database
|
||||
pub fn user_manager(&self) -> &UserManager {
|
||||
&self.manager
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Deref for Request {
|
||||
|
|
|
@ -26,7 +26,7 @@ struct CertificateDef(Vec<u8>);
|
|||
///
|
||||
/// Wraps a [`sled::Db`]
|
||||
pub struct UserManager {
|
||||
db: sled::Db,
|
||||
pub db: sled::Db,
|
||||
pub (crate) users: sled::Tree, // user_id:String maps to data:UserData
|
||||
pub (crate) certificates: sled::Tree, // certificate:u64 maps to data:CertificateData
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ impl UserManager {
|
|||
pub fn new(dir: impl AsRef<Path>) -> Result<Self> {
|
||||
let db = sled::open(dir)?;
|
||||
Ok(Self {
|
||||
users: db.open_tree("users")?,
|
||||
certificates: db.open_tree("certificates")?,
|
||||
users: db.open_tree("gay.emii.kochab.users")?,
|
||||
certificates: db.open_tree("gay.emii.kochab.certificates")?,
|
||||
db,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue