Allow filtering guest/non-guest users

This commit is contained in:
Quentin Gliech
2025-09-15 10:37:34 +02:00
parent a2172a02ba
commit b7015c0b3d
4 changed files with 57 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ impl UserState {
pub struct UserFilter<'a> {
state: Option<UserState>,
can_request_admin: Option<bool>,
is_guest: Option<bool>,
_phantom: std::marker::PhantomData<&'a ()>,
}
@@ -120,6 +121,20 @@ impl UserFilter<'_> {
self
}
/// Filter for guest users
#[must_use]
pub fn guest_only(mut self) -> Self {
self.is_guest = Some(true);
self
}
/// Filter for non-guest users
#[must_use]
pub fn non_guest_only(mut self) -> Self {
self.is_guest = Some(false);
self
}
/// Get the state filter
///
/// Returns [`None`] if no state filter was set
@@ -135,6 +150,14 @@ impl UserFilter<'_> {
pub fn can_request_admin(&self) -> Option<bool> {
self.can_request_admin
}
/// Get the is guest filter
///
/// Returns [`None`] if no is guest filter was set
#[must_use]
pub fn is_guest(&self) -> Option<bool> {
self.is_guest
}
}
/// A [`UserRepository`] helps interacting with [`User`] saved in the storage