diff --git a/crates/core/database/src/models/channel_webhooks/model.rs b/crates/core/database/src/models/channel_webhooks/model.rs index 568326d6..db3a4651 100644 --- a/crates/core/database/src/models/channel_webhooks/model.rs +++ b/crates/core/database/src/models/channel_webhooks/model.rs @@ -70,7 +70,7 @@ impl Webhook { if self.token.as_deref() == Some(token) { Ok(()) } else { - Err(create_error!(InvalidCredentials)) + Err(create_error!(NotAuthenticated)) } } diff --git a/crates/core/database/src/models/users/axum.rs b/crates/core/database/src/models/users/axum.rs index da108a45..da83c5b1 100644 --- a/crates/core/database/src/models/users/axum.rs +++ b/crates/core/database/src/models/users/axum.rs @@ -18,7 +18,7 @@ impl FromRequestParts for User { let session = db.fetch_session_by_token(session_token).await?; db.fetch_user(&session.user_id).await } else { - Err(create_error!(InvalidCredentials)) + Err(create_error!(NotAuthenticated)) } } } diff --git a/crates/core/result/src/axum.rs b/crates/core/result/src/axum.rs index 29c52875..11f1fa1c 100644 --- a/crates/core/result/src/axum.rs +++ b/crates/core/result/src/axum.rs @@ -67,6 +67,7 @@ impl IntoResponse for Error { ErrorType::InvalidCredentials => StatusCode::UNAUTHORIZED, ErrorType::InvalidProperty => StatusCode::BAD_REQUEST, ErrorType::InvalidSession => StatusCode::UNAUTHORIZED, + ErrorType::NotAuthenticated => StatusCode::UNAUTHORIZED, ErrorType::DuplicateNonce => StatusCode::CONFLICT, ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST, ErrorType::NotFound => StatusCode::NOT_FOUND, diff --git a/crates/core/result/src/lib.rs b/crates/core/result/src/lib.rs index d5d093c7..06ef7810 100644 --- a/crates/core/result/src/lib.rs +++ b/crates/core/result/src/lib.rs @@ -147,6 +147,7 @@ pub enum ErrorType { InvalidCredentials, InvalidProperty, InvalidSession, + NotAuthenticated, DuplicateNonce, NotFound, NoEffect, diff --git a/crates/core/result/src/rocket.rs b/crates/core/result/src/rocket.rs index 2b3a3fb2..6efcb663 100644 --- a/crates/core/result/src/rocket.rs +++ b/crates/core/result/src/rocket.rs @@ -73,6 +73,7 @@ impl<'r> Responder<'r, 'static> for Error { ErrorType::InvalidCredentials => Status::Unauthorized, ErrorType::InvalidProperty => Status::BadRequest, ErrorType::InvalidSession => Status::Unauthorized, + ErrorType::NotAuthenticated => Status::Unauthorized, ErrorType::DuplicateNonce => Status::Conflict, ErrorType::VosoUnavailable => Status::BadRequest, ErrorType::NotFound => Status::NotFound,