dav: get_resource replace principal with User

This commit is contained in:
Lennart
2024-10-31 18:20:43 +01:00
parent a136f86ca7
commit eab03fef6b
11 changed files with 28 additions and 21 deletions

View File

@@ -79,7 +79,7 @@ pub async fn route_propfind<R: ResourceService>(
}
}
let resource = resource_service.get_resource(user.id).await?;
let resource = resource_service.get_resource(user).await?;
let response = resource.propfind(req.path(), props, req.resource_map())?;
Ok(MultistatusElement {

View File

@@ -76,7 +76,7 @@ pub async fn route_proppatch<R: ResourceService>(
})
.collect();
let mut resource = resource_service.get_resource(user.id).await?;
let mut resource = resource_service.get_resource(user).await?;
let mut props_ok = Vec::new();
let mut props_conflict = Vec::new();

View File

@@ -11,6 +11,7 @@ use actix_web::{http::StatusCode, HttpRequest, ResponseError};
use async_trait::async_trait;
use core::fmt;
use itertools::Itertools;
use rustical_store::auth::User;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use strum::VariantNames;
@@ -153,7 +154,7 @@ pub trait ResourceService: Sized + 'static {
Ok(vec![])
}
async fn get_resource(&self, principal: String) -> Result<Self::Resource, Self::Error>;
async fn get_resource(&self, user: User) -> Result<Self::Resource, Self::Error>;
async fn save_resource(&self, file: Self::Resource) -> Result<(), Self::Error>;
async fn delete_resource(&self, _use_trashbin: bool) -> Result<(), Self::Error> {
Err(crate::Error::Unauthorized.into())