user restricted to own objects

This commit is contained in:
Per Stark
2024-12-15 22:52:34 +01:00
parent ae4781363f
commit 291c473d00
18 changed files with 109 additions and 28 deletions

View File

@@ -66,6 +66,8 @@ pub enum ApiError {
UserAlreadyExists,
#[error("User was not found")]
UserNotFound,
#[error("You must provide valid credentials")]
AuthRequired,
}
impl IntoResponse for ApiError {
@@ -78,6 +80,7 @@ impl IntoResponse for ApiError {
ApiError::OpenAIerror(_) => (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()),
ApiError::QueryError(_) => (StatusCode::BAD_REQUEST, self.to_string()),
ApiError::UserAlreadyExists => (StatusCode::BAD_REQUEST, self.to_string()),
ApiError::AuthRequired => (StatusCode::BAD_REQUEST, self.to_string()),
ApiError::UserNotFound => (StatusCode::BAD_REQUEST, self.to_string()),
ApiError::IngressContentError(_) => {
(StatusCode::INTERNAL_SERVER_ERROR, self.to_string())