diff options
Diffstat (limited to '')
| -rw-r--r-- | crates/rocie-server/src/api/get/auth/unit.rs (renamed from crates/rocie-server/src/api/get/unit.rs) | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/rocie-server/src/api/get/unit.rs b/crates/rocie-server/src/api/get/auth/unit.rs index caafaa3..980d9c7 100644 --- a/crates/rocie-server/src/api/get/unit.rs +++ b/crates/rocie-server/src/api/get/auth/unit.rs @@ -1,3 +1,4 @@ +use actix_identity::Identity; use actix_web::{HttpResponse, Responder, Result, get, web}; use crate::{ @@ -17,6 +18,10 @@ use crate::{ body = Vec<Unit> ), ( + status = UNAUTHORIZED, + description = "You did not login before calling this endpoint", + ), + ( status = INTERNAL_SERVER_ERROR, description = "Server encountered error", body = String @@ -24,7 +29,7 @@ use crate::{ ), )] #[get("/units/")] -pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { +pub(crate) async fn units(app: web::Data<App>, _user: Identity) -> Result<impl Responder> { let all = Unit::get_all(&app).await?; Ok(HttpResponse::Ok().json(all)) @@ -39,6 +44,10 @@ pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { body = Vec<Unit> ), ( + status = UNAUTHORIZED, + description = "You did not login before calling this endpoint", + ), + ( status = INTERNAL_SERVER_ERROR, description = "Server encountered error", body = String @@ -55,6 +64,7 @@ pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { pub(crate) async fn units_by_property_id( app: web::Data<App>, id: web::Path<UnitPropertyIdStub>, + _user: Identity, ) -> Result<impl Responder> { let id = id.into_inner(); let all = Unit::get_all(&app) @@ -75,6 +85,10 @@ pub(crate) async fn units_by_property_id( body = Unit ), ( + status = UNAUTHORIZED, + description = "You did not login before calling this endpoint", + ), + ( status = NOT_FOUND, description = "Unit not found in database" ), @@ -95,6 +109,7 @@ pub(crate) async fn units_by_property_id( pub(crate) async fn unit_by_id( app: web::Data<App>, id: web::Path<UnitIdStub>, + _user: Identity, ) -> Result<impl Responder> { let id = id.into_inner(); |
