feat: Start implementing roles (and domainless service users)

This commit is contained in:
selfhoster selfhoster 2026-09-04 18:35:46 +02:00
commit 10548295cd
10 changed files with 156 additions and 21 deletions

View file

@ -5,12 +5,18 @@ use crate::db::UserRef;
pub type BoxedError = Box<dyn std::error::Error + Send + Sync + 'static>;
#[derive(Debug)]
pub struct UserAlreadyExists(pub UserRef);
pub enum UserCreationError {
UserAlreadyExists(UserRef),
Permissions,
}
impl fmt::Display for UserAlreadyExists {
impl fmt::Display for UserCreationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "User already exists: {}", self.0)
match self {
Self::UserAlreadyExists(user) => write!(f, "User already exists: {user}"),
Self::Permissions => write!(f, "You do not have permissions to create this user"),
}
}
}
impl std::error::Error for UserAlreadyExists {}
impl std::error::Error for UserCreationError {}