feat: List domains user can see on homepage
This commit is contained in:
parent
58a8c375f0
commit
8a7e644960
11 changed files with 136 additions and 58 deletions
|
|
@ -3,7 +3,7 @@ use tokio::sync::RwLock;
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::db::error::BoxedError;
|
||||
use crate::db::{DatabaseInterface, UserRef};
|
||||
use crate::db::{DatabaseInterface, Domain, User, UserRef};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Database<D: DatabaseInterface> {
|
||||
|
|
@ -36,4 +36,13 @@ impl<D: DatabaseInterface> Database<D> {
|
|||
tracing::debug!("Comparing {} and {}", user.password, password);
|
||||
Ok(user.password == password)
|
||||
}
|
||||
|
||||
pub async fn domains_user_can_see(&self, user: &User) -> Result<Vec<Domain>, BoxedError> {
|
||||
Ok(self
|
||||
.list_all_domains()
|
||||
.await?
|
||||
.into_iter()
|
||||
.filter(|d| user.role.can_see_domain(&d.name))
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue